Reputation: 9378
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",
Upvotes: 0
Views: 5622
Reputation: 1
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>
Upvotes: 0
Reputation: 63956
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.
Upvotes: 5
Reputation: 7761
Try and replace the url
parameter with:
url: "/MainService.asmx/UpdateInformation",
or
url: "MainService.asmx/UpdateInformation",
Upvotes: 1