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",
Use 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.