7 ajax jquery json synchronous
我需要对last.fm API发出同步请求,但是当我一起使用GET和json时,请求变为异步.
我的代码:
$.ajax({
async: false,
dataType: "json",
url: "http://ws.audioscrobbler.com/2.0/?method=artist.getimages&artist="+artist+"&api_key="+apiKey+"&format=json&callback=?",
success: function(html){
imgURL = html.images.image[1].sizes.size[0]["#text"];
}
});
Run Code Online (Sandbox Code Playgroud)
如果我删除dataType:"json"或使用POST,它再次同步,但我依赖于同时使用json和GET.
有任何想法吗?