问题描述
我做的Ajax调用使用jQuery和我的网址是像
I am doing Ajax call using jQuery and my URL is like
的http://本地主机; 3327 / DummyAps / Demo.aspx
在Demo.aspx页我有一个WebMethod,我想叫。虽然这样做jQuery的AJAX调用我给的网址为/ DemoWebMethod,其中DemoWebMethod是的WebMethod present在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.
不过,尽管调用的WebMethod被调用的网址的http://本地主机; 3327 / DummyAps / DemoWebMethod 但我想打电话给的http://本地主机; 3327 / DummyAps / Demo.aspx / DemoWebMethod
But while calling the WebMethod it is calling the URL http://localhost;3327/DummyAps/DemoWebMethod but i want to callhttp://localhost;3327/DummyAps/Demo.aspx/DemoWebMethod.
我知道,改变从/ DemoWebMethod的网址为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).
有人可以帮我吗?
推荐答案
这应该这样做,如果你想整个网址:
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
这篇关于如何获得当前页面路径的jQuery(同时做AJAX调用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!