2

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 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.