Anyway to delay JS call?

This is what I have:
  I have a hidden field on an aspx page. I have a sumbit button. I do a database save on the click event and get an OrderID.
 BUT,on Onclick event of the button, i first call a JS function. When I call this JS, I still dont have the OrderId.

 JS function gets called it, that's why the hidden field is empty.

Anyway to call this JS AFTER I get the orderID??

function ReloadParentPage()

        alert(document.getElementById('ctl00_Body_orderIdHidden').value); //This is EMPTY
      window.opener.location.href = "POrder.aspx?" + document.getElementById('ctl00_Body_orderIdHidden').value;

Who is Participating?
Pawel WitkowskiConnect With a Mentor Senior Javascript DeveloperCommented:
simplest solution is to use setTimeout:

    //  this function will be executed after miliseconds that you give in next parameter

}, 4000);

so it will fire this function after 4 sec.
Gibu GeorgeConnect With a Mentor Chief Technology OfficerCommented:
setTimeout(" ReloadParentPage()", 1000), this will execute the  ReloadParentPage() function after 1 second
Pawel WitkowskiSenior Javascript DeveloperCommented:
I would rather never use string as a parameter for setTimeout, setInterval function, because its beeing evaled (that is evil -> read about it on web) :)))
CamilliaAuthor Commented:
let me try
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.