admin管理员组文章数量:1391991
I recently added some url re-writing to my web application and had to added Page.Resolve URL to all my script images etc references. Now inside of those scripts, i have some ajax calls that now is not finding my webservices anymore. the Request URL is wrong i see looking at the error message. Is there anyway I can get to my webservices? thanks for any help.
What I had orginally thats not working now
$.ajax({
type: "POST",
url: "../MainService.asmx/UpdateInformation",
contentType: "application/json; charset=utf-8",
data: parameter,
dataType: "json",
I recently added some url re-writing to my web application and had to added Page.Resolve URL to all my script images etc references. Now inside of those scripts, i have some ajax calls that now is not finding my webservices anymore. the Request URL is wrong i see looking at the error message. Is there anyway I can get to my webservices? thanks for any help.
What I had orginally thats not working now
$.ajax({
type: "POST",
url: "../MainService.asmx/UpdateInformation",
contentType: "application/json; charset=utf-8",
data: parameter,
dataType: "json",
Share
Improve this question
asked Mar 20, 2012 at 14:03
user516883user516883
9,42823 gold badges76 silver badges115 bronze badges
3 Answers
Reset to default 5Use this instead:
url: '<%=ResolveClientUrl("~/MainService.asmx/UpdateInformation")%>',
This will resolve the correct URL independently of the path the user is on. Note the ~
. This means that the path will start at the root of the website.
Try and replace the url
parameter with:
url: "/MainService.asmx/UpdateInformation",
or
url: "MainService.asmx/UpdateInformation",
Could always add something like this
<script type="text/javascript">
<% var siteroot = Url.Content("~/") %>
$.ajax({
type: "POST",
url: siteroot + "MainService.asmx/UpdateInformation",
contentType: "application/json; charset=utf-8",
data: parameter,
dataType: "json",
</script>
本文标签: cURL for ajax not working properly in aspnetStack Overflow
版权声明:本文标题:c# - URL for ajax not working properly in asp.net - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744734555a2622247.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论