How to return a variable from a $.getJSON function?
You can't get value when calling getJSON because getJSON is an async call. Any code that you want to execute with the results of the getJSON call needs to happen either within that callback function or after the callback executes.

$.getJSON(url, data, callback(result) {or
// Do something with result here
});
$.getJSON(url, data, callback(result)});
function callback (result){ // Do something with result here }
No comments:
Post a Comment