简体   繁体   中英

How to get requested url from ajax response?

In my project I have several ajax global events.

In

$(document).ajaxSend(function(event, jqxhr, settings) {
   // 
});

I can get requested url from settings.url

But how can I get url from response from this request in

$(document).ajaxComplete(function (e, jqxhr) {
    //
});

The only object that contains requested url here is arguments[2].url

Is there other way to obtain requested url from response, because I'm not sure in such object as arguments[2].url ?

arguments[2] is exactly the same as settings

$(document).ajaxComplete(function (e, jqxhr, settings) {
    // arguments[2] === settings
});

in your complete of ajax try using like this:

$( document ).ajaxComplete(function( event, xhr, settings ) {
  alert(settings.url);
});

see documentation here

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM