jQuery Deferred not working
问题 I am trying out a code as function search(query) { var dfr = $.Deferred(); $.ajax({ url: "http://search.twitter.com/search.json", data: { q: query }, dataType: 'jsonp', success: dfr.resolve }); return dfr.promise(); } Test = { start: function(){ alert("Starting"); } }; function gotresults(data) { alert(data.max_id); } function showDiv() { $('<div />').html("Results received").appendTo('body'); } $.when(search('ashishnjain')) .then(gotresults) .then(showDiv); This works as expected. However