I have one method say method1 in java script that is having another method say method2 call. method2 returns one value whi
Don't have method2
return a value. Instead, pass a callback function to method2
which will execute once the value has been fetched:
function method2(firstData, completionCallback) {
var dataArray = new Array();
$.indexedDB("SelfAssessment").objectStore("First_Sheet", "readonly").each(function(elem) {
dataArray.push(elem.value);
}).done(function() { completionCallback(dataArray) });
}
And invoke it like this:
function method1(){
method2(userObj.first, function(dataArray) {
// inside a function that is called by method2 when the value is fetched
alert("dataArray size -"+dataArray.length);
// do everything with dataArray inside this function
});
}