开发者

Retrieve jQuery requested ajax URL and compare if matches

开发者 https://www.devze.com 2023-01-19 01:41 出处:网络
I am trying to grab the requested AJAX URL generated by a plugin to use in my callback. My intention is, to say in plain English: If the current requested AJAX URL matches attribute href in a certain

I am trying to grab the requested AJAX URL generated by a plugin to use in my callback. My intention is, to say in plain English: If the current requested AJAX URL matches attribute href in a certain selector already available in the page, then do something.

  $(selector).myplugin({settings},function(){
    if (currentAjaxURL == 开发者_开发技巧$(another selector).attr('href') ) {
      // do something
    }
  });

Is there any way for jQuery to get currentAjaxURL via the active current requested URL? Any hint would be very much appreciated.

Thanks


Look at the global ajax events in the jquery docs, you can listen for requests being sent (before they send, when they start, when they complete etc...) and get the XMLHttpRequest object directly, then you could compare the URL to the dom element's href attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消