Retrieve jQuery requested ajax URL and compare if matches
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.
精彩评论