Validation plugin overrides and breaks jQuery ajax function

Validation plugin overrides and breaks jQuery ajax function

The validation plugin overrides the $.ajax function as follows:

  1. // ajax mode: abort // usage: $.ajax({ mode: "abort"[, port: "uniqueport"]}); // if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() ;(function($) { var ajax = $.ajax; var pendingRequests = {}; $.ajax = function(settings) { // create settings for compatibility with ajaxSetup settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings)); var port = settings.port; if (settings.mode == "abort") { if ( pendingRequests[port] ) { pendingRequests[port].abort(); } return (pendingRequests[port] = ajax.apply(this, arguments)); } return ajax.apply(this, arguments); }; })(jQuery);

And this causes the following code to act weird and fail:

  1. var jxhr = jQuery.ajax('/foo.php', {type:'post'});

    • Topic Participants

    • bryan