Reputation: 2719
I have this the below code
$.ajax({
url: "search/prefetch",
success: function (data) {
$(".result").html(data);
alert("Load was performed.");
},
dataType: "json"
});
the request, however, is made to http://<myhost>/<another-path>/search/prefetch
This request is performed when the current page is http://<myhost>/<another-path>/<some-other-paths>
How can I make the request to http://<myhost>/search/prefetch
?
Upvotes: 0
Views: 337
Reputation: 983
Relativity is the answer.
search/prefetch
=> mysite.com/<current_uri>/search/prefetch
/search/prefetch
=> mysite.com/search/prefetch
Upvotes: 1
Reputation: 36311
Just prefix your url with a /
$.ajax({
url: "/search/prefetch",
success: function (data) {
$(".result").html(data);
alert("Load was performed.");
},
dataType: "json"
});
What you are currently doing is telling the browser to take the current url path and append this path to the end of it. By prefixing it with a /
you now are telling the browser to take the current url path and replace it with this new path.
Upvotes: 2