The following code returns 'cannot read property 'done' of undefined'. I want function2 to run when function1 is done:
function1 = function() {
console.log("hi");
}
function1();
function1().done(function2);
EDIT: Not sure if I did this correct, but I tried promise and that didn't work either:
var p = new Promise(function(resolve, reject) {
var test = window.location.search.substring(1) + ".html";
console.log(test);
$("#main-content").load(test);
if($("#main-content") != null) {
resolve('Success!');
function2();
}
else {
reject('Failure!');
}
});
function2 does run, but not async.