Skip to content

Commit

Permalink
Fixed #1557, although it doesn't appear to be just an FF3 problem. In…
Browse files Browse the repository at this point in the history
… this case, $.getJSON() wasn't working from a remote host. I went ahead and added a unit test then added the s.dataType == "json" test for a remote <script> load. The said that json was allowed but the dataType check was missing. This appears to have fixed the bug across all browsers.
  • Loading branch information
davids549 committed Nov 29, 2007
1 parent 7ac564c commit 4b8f6cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ajax.js
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/data/json_assigned_obj.js
@@ -0,0 +1 @@
json_assigned_obj = { "test" : "worked" };
13 changes: 13 additions & 0 deletions test/unit/ajax.js
Expand Up @@ -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();
Expand Down

0 comments on commit 4b8f6cd

Please sign in to comment.