这是因为jQuery.when()需要jQuery.Deferred实例,而load()返回jQuery实例(请参见http://api.jquery.com/jQuery.when/和http://api.jquery.com/load/)。
您可以解决此问题:
// Create two Deferred instances that can be handed to $.when()var d1 = new $.Deferred();var d2 = new $.Deferred();// Set up the chain of events...$.when(d1, d2).then(function() { alert('done');});// And finally: Make the actual ajax calls:$('#detail1').load('/getInfo.php', function() { d1.resolve(); });$('#detail2').load('/getOther.php', function() { d2.resolve(); });


