jQuery ajax call with async false is not working
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here I have pasted my code, I want to return the response of $.ajax as response of function a(). But before the result comes up of ajax call, it is returning the empty f. please help on this a = function() { var f = ''; $.ajax({ url: 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=immaulikvora&count=1&page=1&include_entities=1&callback=?', dataType: 'json', async: false, success: function(data) { f = data; } }); return f; }; var lid = a(); alert(lid); 回答1: I guess you are using jQuery 1.8+ http://api.jquery.com/jQuery.ajax/