Loading ...
Sorry, an error occurred while loading the content.

Re: multiple asyncRequests at the same time?

Expand Messages
  • jessekeller
    ... Here you go. It s pretty simple -- hopefully you ll see what it is I m doing wrong. Here s what happens when I run this: 1. PollForStatus fires, and
    Message 1 of 3 , Apr 16, 2006
    • 0 Attachment
      --- In ydn-javascript@yahoogroups.com, Matt Warden <mwarden@...> wrote:
      >
      > jessekeller wrote:
      > > Why is the monitor request waiting for the other
      > > request?
      >
      > Code?


      Here you go. It's pretty simple -- hopefully you'll see what it is I'm
      doing wrong. Here's what happens when I run this:

      1. PollForStatus fires, and displays a progress report

      2. do-long-process fires, and the server begins crunching on the long
      process

      3. After 15 seconds, do-long-process finishes, and PollForStatus
      immediately fires a second time, reporting that do-long-process is
      complete.

      Question: why didn't PollForStatus fire during the 15 seconds that
      do-long-process was running?



      function Page_Load () {

      // Start the progress meter
      PollForStatus();

      // Now begin the long process

      var callback = {
      failure: AjaxFailure
      }

      var url = 'do-long-process.html';

      var cObj = YAHOO.util.Connect.asyncRequest('GET',url,callback,null);


      }

      function PollForStatus (callback) {

      // Ping the server to see if the long process is still running.

      var callback = {
      success: DisplayStatus,
      failure: AjaxFailure
      }

      url = 'progress.html';

      var cObj = YAHOO.util.Connect.asyncRequest('GET',url,callback,null);

      }

      function DisplayStatus(callback) {

      // Display the progress message

      var response = eval("(" + callback.responseText + ")");

      document.getElementById("divStatus").innerHTML = response.msg;

      // Check for progress again in 2 seconds

      if (response.status < 2)
      setTimeout('PollForStatus()',2000)
      else
      alert("Finished!");

      }
    Your message has been successfully submitted and would be delivered to recipients shortly.