Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  45] [ 5]  / answers: 1 / hits: 15736  / 11 Years ago, mon, april 29, 2013, 12:00:00

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;
},
});


Returning data is null but required to return the userId


More From » jquery

 Answers
5

You need to do this:



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


[#78527] Sunday, April 28, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaelynncherokeeg

Total Points: 697
Total Questions: 109
Total Answers: 104

Location: France
Member since Thu, Mar 18, 2021
3 Years ago
jaelynncherokeeg questions
Thu, May 27, 21, 00:00, 3 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
Thu, Nov 14, 19, 00:00, 5 Years ago
Wed, Sep 18, 19, 00:00, 5 Years ago
;