阿贾克斯不回头任何数据。
Ajax does not turn back any data.
http://jsfiddle.net/w67C4/
$.ajax({
dataType:'jsonp',
url: url,
async:false,
success: function(data){
getUsername = data.user.id;
},
});
返回数据为空,但返回的用户ID需要
Returning data is null but required to return the userId
您需要做的:
function getUserId() {
var url = "http://api.flickr.com/services/rest/?jsoncallback=?&api_key=fc6c52ed4f458bd9ee506912a860e466&method=flickr.urls.lookupUser&format=json&nojsoncallback=1&url=http://www.flickr.com/photos/flickr";
var getUsername = null;
return $.ajax({
dataType: 'jsonp',
url: url,
async: false
});
}
getUserId().done(function (result) {
// Call the alert here..
alert(result.user.id);
});
FIDDLE