Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overwrite ajaxComplete for particular ajax request

Tags:

jquery

ajax

My application has a ajaxComplete() which is defined in a generic .js file loaded in every view page. How can I overwrite this or better still avoid running it for specific $.ajax() call.

like image 536
frictionlesspulley Avatar asked Feb 26 '23 08:02

frictionlesspulley


1 Answers

Set global: false in your $.ajax call.

From the API:

Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered.

Your call will look something like this:

$.ajax({
    url: 'http://example.com/',
    data: data,
    global: false,
    success: function() {

    }/* etc... */
});
like image 92
lonesomeday Avatar answered Mar 08 '23 06:03

lonesomeday