Detection if HTTP method (POST, GET) in jQuery.ajaxComplete ()

Q jQuery.ajaxComplete()how can I detect an HTTP method, specifically GET or POST?

I tried reading jQuery documentation and searching around, and I cannot find much documentation on 3 objects passed to the function handler inside

jQuery(element).ajaxComplete(function(event, request, settings) {    });

thank

+5
source share
1 answer

The object settingsin the AJAX callback is the settings object that was passed to the AJAX call. Therefore, you can search for a property typeto see if it was GET or POST:

jQuery(element).ajaxComplete(function(event, request, settings) {
    alert(settings.type);
});

The parameters you can get this way are the same as the ones you can set using the constructor $.ajax.

+7

All Articles