0

I have an ajax call in my legacy application:

i2b2.CRC.ajax.getQueryResultInstanceList_fromQueryResultInstanceId(
    "CRC:QueryStatus", {qr_key_value: rec.QRS_ID}, scopedCallbackQRSI
);

I want to add this Ajax request in setTimeout method. To escape " I added \. I came up with following line:

setTimeout("i2b2.CRC.ajax.getQueryResultInstanceList_fromQueryResultInstanceId(\"CRC:QueryStatus\", {qr_key_value: rec.QRS_ID}, scopedCallbackQRSI)",50000);

Now I am not getting any error on console but Ajax call is also not working either.

Am I missing anything?

1 Answer 1

1

The rec and/or scopedCallbackQRSI variables are probably defined in a local scope (thus not accessible from the global scope). When setTimeout is called with a stringified function as a first argument, the function is executed within the scope of window.

To maintain the scope (and be able to use the local variables), wrap your code in a function, and pass it as a first argument to setTimeout:

setTimeout(function(){
    i2b2.CRC.ajax.getQueryResultInstanceList_fromQueryResultInstanceId("CRC:QueryStatus", {qr_key_value: rec.QRS_ID}, scopedCallbackQRSI);
}, 50000);
Sign up to request clarification or add additional context in comments.

4 Comments

Ya they are define in local scope. Russ solution looks bit easy I guess.
Russ' "solution" doesn't work, because it's fundamentally not different from your current code.
I tried your solution no error but seems like Ajax request is not triggered.
@Ajinkya This solution should solve your main problem, if the request is not triggered, it's another problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.