How to get current page path in jQuery (while doing ajax call)
I am doing Ajax call using jQuery and my URL is like
http://localhost;3327/DummyAps/Demo.aspx
In Demo.aspx page i have a WebMethod, which i wanted to call. While doing jQuery ajax call i am giving the URL as "/DemoWebMethod", where "DemoWebMethod" is the Webmethod present in Demo.aspx page.
But while calling the WebMethod it is calling the URL http://localhost;3327/DummyAps/DemoWebMethod but i want to call http://localhost;3327/DummyAps/Demo.aspx/DemoWebMethod.
I know that changing the URL from "/DemoWebMethod" to "Demo.aspx/DemoWebMethod" will solve the problem but can i do it without writing that (because i have some problem with that).
Can someone please help me?
This should do it, in case you want the entire url:
window.location.href.split("#")[0]
For just the path, try this:
window.location.pathname
链接地址: http://www.djcxy.com/p/70252.html