jQuery: The Write Less, Do More JavaScript Library

Changeset 4476

Show
Ignore:
Timestamp:
01/17/08 21:38:58 (7 months ago)
Author:
davidserduke
Message:

Fixed #2174 by removing the s.dataType == "json" check for possible cross domain since it causes absolute urls to use a <script> tag ajax retrieval even though absolute urls work fine for retrieving local data. Cross-domain jsonp will still work since the $.ajax() function actually changes the s.dataType to "script" before it reaches this check in cases where it is s.dataType == "jsonp" or s.dataType == "json" and a parameter has =? in it.

Location:
trunk/jquery
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/ajax.js

    r4446 r4476  
    233233        // If we're requesting a remote document 
    234234        // and trying to load JSON or Script with a GET 
    235         if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && ( s.dataType == "script" || s.dataType =="json" ) && s.type.toLowerCase() == "get" ) { 
     235        if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && s.dataType == "script" && s.type.toLowerCase() == "get" ) { 
    236236            var head = document.getElementsByTagName("head")[0]; 
    237237            var script = document.createElement("script"); 
  • trunk/jquery/test/unit/ajax.js

    r4192 r4476  
    650650}); 
    651651 
    652 test("$.getJSON(String, Function) - Remote JSON object with assignment", function() { 
     652test("$.getJSON(String, Function) - JSON object with absolute url to local content", function() { 
    653653    expect(2); 
    654654 
     
    656656 
    657657    stop(); 
    658     $.getJSON(base + "data/json_assigned_obj.js", function() { 
    659       ok( typeof json_assigned_obj == "object", 'Check JSON loaded' ); 
    660       equals( json_assigned_obj.test, "worked", 'Check JSON obj.test' ); 
     658    $.getJSON(url(base + "data/json.php"), function(json) { 
     659      ok( json.data.lang == 'en', 'Check JSON: lang' ); 
     660      ok( json.data.length == 25, 'Check JSON: length' ); 
    661661      start(); 
    662662    });