jQuery ajax call with async false is not working

前端 未结 3 1553
被撕碎了的回忆
被撕碎了的回忆 2020-12-16 07:27

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. pl

3条回答
  •  悲&欢浪女
    2020-12-16 08:00

    Please assign the ajax to jqXHR object and reading the responseText will help you.

     var jqXHR=$.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
        });    
    
    jqXHR.responseText // This will give you the result
    

提交回复
热议问题