]> source.dussan.org Git - jquery.git/commitdiff
Fix #1987 by only doing remote <script> type ajax with GET requests. All other types...
authorDavid Serduke <davidserduke@gmail.com>
Tue, 11 Dec 2007 20:16:19 +0000 (20:16 +0000)
committerDavid Serduke <davidserduke@gmail.com>
Tue, 11 Dec 2007 20:16:19 +0000 (20:16 +0000)
src/ajax.js
test/unit/ajax.js

index 104961497c96b4eeb553a425d70cc669b1ca7d57..bf0cf109f6385d1f0a57ebf2154e466093459d01 100644 (file)
@@ -218,8 +218,8 @@ jQuery.extend({
                        jQuery.event.trigger( "ajaxStart" );
 
                // If we're requesting a remote document
-               // and trying to load JSON or Script
-               if ( !s.url.indexOf("http") && ( s.dataType == "script" || s.dataType =="json" ) ) {
+               // and trying to load JSON or Script with a GET
+               if ( !s.url.indexOf("http") && ( s.dataType == "script" || s.dataType =="json" ) && s.type.toLowerCase() == "get" ) {
                        var head = document.getElementsByTagName("head")[0];
                        var script = document.createElement("script");
                        script.src = s.url;
index 813c65fbc09dc28b7929299b3da2e23f9bd262ff..40ec9641565fb0047293d86a854dd5d912e59794 100644 (file)
@@ -573,6 +573,25 @@ test("$.ajax() - script, Remote", function() {
        });
 });
 
+test("$.ajax() - script, Remote with POST", function() {
+       expect(3);
+
+       var base = window.location.href.replace(/\?.*$/, "");
+
+       stop();
+
+       $.ajax({
+               url: base + "data/test.js",
+               type: "POST",
+               dataType: "script",
+               success: function(data, status){
+                       ok( foobar, "Script results returned (GET, no callback)" );
+                       equals( status, "success", "Script results returned (GET, no callback)" );
+                       start();
+               }
+       });
+});
+
 test("$.getJSON(String, Hash, Function) - JSON array", function() {
        expect(4);
        stop();