Bug Tracker

Changeset 4155

Show
Ignore:
Timestamp:
12/14/07 17:06:41 (9 months ago)
Author:
davidserduke
Message:

Fixed #2046 by forcing the dataType to 'html' in the .load() function.

Location:
trunk/jquery
Files:
2 modified

Legend:

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

    r4149 r4155  
    3535            url: url, 
    3636            type: type, 
     37            dataType: "html", 
    3738            data: params, 
    3839            complete: function(res, status){ 
  • trunk/jquery/test/unit/ajax.js

    r4123 r4155  
    318318}); 
    319319 
     320test("load(String, Function) with ajaxSetup on dataType json, see #2046", function() { 
     321    expect(1); 
     322    stop(); 
     323    $.ajaxSetup({ dataType: "json" }); 
     324    $("#first").ajaxComplete(function (e, xml, s) { 
     325        equals( s.dataType, "html", "Verify the load() dataType was html" ); 
     326        $("#first").unbind("ajaxComplete"); 
     327        $.ajaxSetup({ dataType: "" }); 
     328        start(); 
     329    }); 
     330    $('#first').load("data/test3.html"); 
     331}); 
     332 
    320333test("load(String, Function) - simple: inject text into DOM", function() { 
    321334    expect(2); 
     
    333346    window.foobar = null; 
    334347    var verifyEvaluation = function() { 
    335       equals( foobar, "bar", 'Check if script src was evaluated after load' ); 
    336       equals( $('#ap').html(), 'bar', 'Check if script evaluation has modified DOM'); 
    337     start(); 
     348        equals( foobar, "bar", 'Check if script src was evaluated after load' ); 
     349        equals( $('#ap').html(), 'bar', 'Check if script evaluation has modified DOM'); 
     350        start(); 
    338351    }; 
    339352    $('#first').load(url('data/test.html'), function() { 
    340       ok( $('#first').html().match(/^html text/), 'Check content after loading html' ); 
    341       equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM'); 
    342       equals( testFoo, "foo", 'Check if script was evaluated after load' ); 
    343       setTimeout(verifyEvaluation, 600); 
     353        ok( $('#first').html().match(/^html text/), 'Check content after loading html' ); 
     354        equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM'); 
     355        equals( testFoo, "foo", 'Check if script was evaluated after load' ); 
     356        setTimeout(verifyEvaluation, 600); 
    344357    }); 
    345358}); 
     
    350363    testFoo = undefined; 
    351364    $('#first').load(url('data/test2.html'), function() { 
    352       ok( $('#foo').html() == 'foo', 'Check if script evaluation has modified DOM'); 
    353       ok( testFoo == "foo", 'Check if script was evaluated after load' ); 
    354       start(); 
     365        ok( $('#foo').html() == 'foo', 'Check if script evaluation has modified DOM'); 
     366        ok( testFoo == "foo", 'Check if script was evaluated after load' ); 
     367        start(); 
    355368    }); 
    356369});