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

后端 未结 1 602
我在风中等你
我在风中等你 2021-01-05 21:22

In a jQuery.ajaxComplete() how can I detect the HTTP method, specifically a GET or a POST?

I\'ve tried reading the jQuery documentation and searching a

相关标签:
1条回答
  • 2021-01-05 21:42

    The settings object in the AJAX callback is the settings object that was passed into the AJAX call. You can therefore look for the type property on it to see whether it was GET or POST:

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

    The settings that you can retrieve in this manner are the same as those that you can set with the $.ajax constructor.

    0 讨论(0)
提交回复
热议问题