1

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?

Deviprasad Das
  • 4,203
  • 7
  • 36
  • 51
  • possible duplicate of [Get current URL with javascript?](http://stackoverflow.com/questions/1034621/get-current-url-with-javascript) – Lazarus Aug 18 '10 at 11:51
  • possible duplicate of http://stackoverflow.com/questions/406192/how-to-get-the-current-url-in-jquery as well – Ankit Jaiswal Aug 18 '10 at 11:53
  • But if my url is like Demo.aspx#divNote or something like this then it is not working. In this case i have to get the whole URL and find out the exact page name. – Deviprasad Das Aug 18 '10 at 11:53

1 Answers1

5

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
mporkola
  • 111
  • 5