I have the following function:
function loginStudent() { var advisorKEY = "<dtml-var expr="py_get_alias()">"; var studentKEY = "<dtml-var SID>"; var URL = "py_logging_sessionOpen?AdvisorKEY=" + advisorKEY + "&StudentKEY=" + studentKEY; key = ""; $j.get(URL, function(data) { key = data; }); alert(key); } The py_loggin_sessionOpen is just a python script running on my server.
It returns a single string. I need the response of that script to determine the next action. The script returns the value perfectly, and I can easily check the value by putting an alert within the function(data) in get.
My main question is: how to get the key value to be changed outside the scope of function(data)?
I assumed because I defined it externally it would act as a global variable. Moving it outside loginStudent() does not solve the problem either.
Any ideas?
alert(key)is being called before the value ofkeyis set by the async. function.