Basically I'm testing some javascript with two pretty complicated systems and I don't really know javascript that well, but it boils down to the problem below.
I am calling the javascript function below from another system, all this system can do is call the script and return the return type as a string.
The following code basically makes async calls to a url and returns some json, problem I have is the function finishes and returns before I can assert the content of the variables, how do wait till my variables are not null?
Thanks for any help
I am calling the javascript function below from another system, all this system can do is call the script and return the return type as a string.
The following code basically makes async calls to a url and returns some json, problem I have is the function finishes and returns before I can assert the content of the variables, how do wait till my variables are not null?
Code:
function test2(){
var wrapper = new music.ApiWrapper(null);
var returnContentSuc = null;
var returnContentErr = null;
wrapper.doSearch({
q: 'snoop'
}, function(responseObj){
alert('search successfull callback');
returnContentSuc = responseObj;
},function(errorResult){
alert('search error calback');
returnContentErr = errorResult;
});
**How do I wait here until my returnContent variables are not null?**
//assert the returned variables here are correct and return pass fail
return pass/fail;
};
Thanks for any help