when sending a jquery request and recieving response how to know the url of the request from the response ?
may be like this
function onResoponse(response,url){
requestUrl=url
}
when sending a jquery request and recieving response how to know the url of the request from the response ?
may be like this
function onResoponse(response,url){
requestUrl=url
}
Consider the following example.
https://jsfiddle.net/Twisty/kcbp57z4/
JavaScript
$.ajax({
url: u,
method: "POST",
data: d[i],
success: function(resp, stat, xhr) {
console.log(stat, this.url);
},
error: function(xhr, stat, err) {
console.log(stat, err, this.url);
}
});
You can use this
to refer to the AJAX object itself. From here you can reference the url
properly of the AJAX Object. So if you have multiple AJAX Calls, you can see what URL was used using this.url
within the Success callback.