[jQuery] getJSON - need some direction please.
Hi everyone, thanks is advance for your help.
I am working on a getJSON call to my website from a popup window that
is connected through a Run Time Environment API. I am calling a
function called Initialize(). The call is being made and the data
returned properly. The crazy thing is that I need to return a simple
"true" or "false" but the crazy thing is that once the call
to .getJSON is made, whatever is executing this code (Browser??) is
not waiting for the function call within the .getJSON to complete
which is where the true/false is returned. Can anyone point me in the
right direction on what terms to search under or suggest how to
rewrite my code? Thanks so much.
CODE:
//SORM_API is actaully an object.
function SCORM_API() {
this.Initialize = function() {
//return true or false
//example path would be: cdlonline/node/110/scorm_api/Initialize
var cdlurl = Drupal.settings.basePath + "node/" +
Drupal.settings.company_sco.nid + "/scorm_api/Initialize";
//The browser doesn't wait for this .getJSON call to finish, it
moves on without it. Help. Thanks.
$.getJSON(cdlurl, function(data){
//var below becomes the true/false being returned from the
call to cdlurl.
var Init_ret = data.company_rte_Initialize.ret; //working.
Becomes true or false.
return Init_ret; // where does this return to??
});
return /*need to return true or false from above .getJSON call but
browser doesn't wait for the above to finish and I also don't know
how to get the return value from the Init_ret in the above function.*/
}
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home