-3

My ajax call is not returning anything! Here is my code:

var answer;
$.getJSON('/foo.json') . done(function(response) { answer = response.data; });
console.log(answer);

Even though the network call is succeeding, and I can see that the response contains data, the console logs "undefined"! What is happening?

0 Answers0