I need to execute a few scripts on a page whose ajax requests (onchange/onclick on different elements) are constructed using a custom framework that I cannot change. Fundamentally, I would like to, on successful completion of specific request, execute a few scripts that I have written. Is it possible to use ajaxComplete() or ajaxSuccess() when the ajax call was not initiated using jQuery?
1 Answer
No. Those are part of the event handling jQuery adds to the events it fires off itself.
I don't think there's an event fired when any ajax request at all finishes; your best option is to wrap the XHR constructor before loading this other framework and restore it afterwards. Even that may not work depending on what the framework is actually doing.
Can you be more specific about what this other code is and what you want to add to it? There are events that fire when the page is mutated, for instance, which might be more appropriate.
1 Comment
stavarotti
The scripts I would like to run on success of the ajax request largely decorate the page (primarily hiding and/or showing other elements) in addition to mutating other page elements based on the data returned in the request.