[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

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;

  • 2
2 Solutions
Pawel WitkowskiSenior 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 GeorgeCTOCommented:
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now