]> source.dussan.org Git - jquery.git/commitdiff
Ajax: support non-RFC2616 methods for oldIE
authorOleg <markelog@gmail.com>
Sun, 22 Dec 2013 04:53:19 +0000 (08:53 +0400)
committerOleg <markelog@gmail.com>
Mon, 13 Jan 2014 20:38:38 +0000 (00:38 +0400)
Closes gh-1466
Fixes #13240

src/ajax/xhr.js
test/unit/ajax.js

index d747093d51bc0a8841bd3d5cd31c5afdbc55f3a1..0f560f45a2b058067a18e74e99cb673ff22d0983 100644 (file)
@@ -8,9 +8,20 @@ define([
 // (This is still attached to ajaxSettings for backward compatibility)
 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
        // Support: IE6+
-       // XHR cannot access local files, always use ActiveX for that case
        function() {
-               return !this.isLocal && createStandardXHR() || createActiveXHR();
+
+               // XHR cannot access local files, always use ActiveX for that case
+               return !this.isLocal &&
+
+                       // Support: IE7-8
+                       // oldIE XHR does not support non-RFC2616 methods (#13240)
+                       // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
+                       // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
+                       // Although this check for six methods instead of eight
+                       // since IE also does not support "trace" and "connect"
+                       /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
+
+                       createStandardXHR() || createActiveXHR();
        } :
        // For all other browsers, use the standard XMLHttpRequest object
        createStandardXHR;
index 766a1b6a94a82dc16c83d2dc00df27cbf54cd803..c52f1cdd96f1039728507b4ea90c2efe5d051eb1 100644 (file)
@@ -1575,6 +1575,17 @@ module( "ajax", {
                }
        } );
 
+       ajaxTest( "#13240 - jQuery.ajax() - support non-RFC2616 methods", 1, {
+               url: "data/echoQuery.php",
+               method: "PATCH",
+               success: function() {
+                       ok( true, "success" );
+               },
+               error: function() {
+                       ok( false, "error" );
+               }
+       });
+
        // Support: Chrome 31.
        // Chrome 31 doesn't fire Ajax requests in beforeunload event handler.
        // There is no way for us to workaround it and it's been fixed in Chrome 32