Skip to content

Commit

Permalink
Fix #1987 by only doing remote <script> type ajax with GET requests. …
Browse files Browse the repository at this point in the history
…All other types will be passed on to XMLHttpRequest.
  • Loading branch information
davids549 committed Dec 11, 2007
1 parent 227f8b2 commit c6a44c7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ajax.js
Expand Up @@ -218,8 +218,8 @@ jQuery.extend({
jQuery.event.trigger( "ajaxStart" ); jQuery.event.trigger( "ajaxStart" );


// If we're requesting a remote document // If we're requesting a remote document
// and trying to load JSON or Script // and trying to load JSON or Script with a GET
if ( !s.url.indexOf("http") && ( s.dataType == "script" || s.dataType =="json" ) ) { if ( !s.url.indexOf("http") && ( s.dataType == "script" || s.dataType =="json" ) && s.type.toLowerCase() == "get" ) {
var head = document.getElementsByTagName("head")[0]; var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script"); var script = document.createElement("script");
script.src = s.url; script.src = s.url;
Expand Down
19 changes: 19 additions & 0 deletions test/unit/ajax.js
Expand Up @@ -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() { test("$.getJSON(String, Hash, Function) - JSON array", function() {
expect(4); expect(4);
stop(); stop();
Expand Down

0 comments on commit c6a44c7

Please sign in to comment.