I am making jquery calls to get and getJSON, but cannot access returned values outside of callback function. How can I access the returned data?
var
ALL AJAX CALLS ARE ASYNCHRONOUS
SO you need to use callbacks. anything outside that will return undefined.
$.get(callUrl, function(data) { // call to add node
var n = data.indexOf("id-");
var m = data.indexOf("id-");
firstid = data.substr(n+3,m - (n+3));
nextid = data.substr(m+3);
doSomethingWithFirst(firstid);
});
function doSomethingWithFirst(f) {
//NOW do something
}