Can't use data returned from ajax call in seperate .js file ????
I've been trying to figure this out for a long time (and thanks to those here who have helped) and I'm slowly getting how promise works in jquery (at least I think). My issue still seems to be using the return in another file...
So I have a file called request.js with this code,
function testAjax() {
return $.ajax({
type: 'GET',
url: 'https://www.sciencebase.gov/catalog/items?parentId=504108e5e4b07a90c5ec62d4&max=60&offset=0&format=jsonp',
jsonpCallback: 'getSBJSON',
contentType: "application/json",
dataType: 'jsonp'
});
}
var promise = testAjax();
and then I have a file called requestDone.js with this code,
promise.success(function (json) {
alert(json.total);
});
When they are in the same file it works fine, but when I separate them it doesn't ??
The file for request.html refers only to the request.js script and the requestDone.html file refers only to the requestDone.js script.
What am I doing wrong ???