diff --git a/src/ajax.js b/src/ajax.js index 8e7655cb92..6821cecc4b 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -217,7 +217,7 @@ jQuery.extend({ // If we're requesting a remote document // and trying to load JSON or Script - if ( !s.url.indexOf("http") && s.dataType == "script" ) { + if ( !s.url.indexOf("http") && ( s.dataType == "script" || s.dataType =="json" ) ) { var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.src = s.url; diff --git a/test/data/json_assigned_obj.js b/test/data/json_assigned_obj.js new file mode 100644 index 0000000000..867251dad1 --- /dev/null +++ b/test/data/json_assigned_obj.js @@ -0,0 +1 @@ +json_assigned_obj = { "test" : "worked" }; diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 162650f3be..3e2ac9f2b7 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -513,6 +513,19 @@ test("$.getJSON(String, Function) - JSON object", function() { }); }); +test("$.getJSON(String, Function) - Remote JSON object with assignment", function() { + expect(2); + + var base = window.location.href.replace(/\?.*$/, ""); + + stop(); + $.getJSON(base + "data/json_assigned_obj.js", function() { + ok( typeof json_assigned_obj == "object", 'Check JSON loaded' ); + equals( json_assigned_obj.test, "worked", 'Check JSON obj.test' ); + start(); + }); +}); + test("$.post(String, Hash, Function) - simple with xml", function() { expect(4); stop();