Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET - jQuery ajax calls queue instead of running concurrently?
    primarykey
    data
    text
    <p>I have to do some processing on a file loaded by the user. This process can take a long time based on the number of pages within the file. I am planning on using jQuery UIs progressbar and telling the user how many pages have been processed. However, my progress check does not return until the first ajax call is complete. Both calls complete properly are connecting to the corresponding web methods.</p> <p>I researched this a little bit already, and I found <a href="https://stackoverflow.com/a/4863630/2486">this answer</a> to another question which pretty much stated that if both calls use the Session they wont process concurrently. I only use the Session in one of the calls though.</p> <p>What am I missing?</p> <p>This is the initial call that starts the processing of the file. I set the UpdateProgressBar to run a second after the processing of the file starts.</p> <pre><code>setTimeout("UpdateProgressBar();", 1000); $.ajax({ type: "POST", async: true, data: // my params go here url: // path to web method contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { // Do stuff when file is finished processing }, error: function (XMLHttpRequest, textStatus, errorThrown) { if (errorThrown != null) alert(textStatus + " : " + errorThrown); } }); </code></pre> <p>This is the UpdateProgressBar function:</p> <pre><code>function UpdateProgressBar() { $.ajax({ type: "POST", async: true, data: // my params go here url: // path to web method contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var totalPages = parseInt($('[id$=lbl_PageCount]').text()); var pagesProcessed = result.d; var percentProcessed = pagesProcessed / totalPages; $('#div_ProgressBar').progressbar("value", percentProcessed); if (pagesProcessed &lt; totalPages) setTimeout("UpdateProgressBar();", 800); }, error: function (XMLHttpRequest, textStatus, errorThrown) { if (errorThrown != null) alert(textStatus + " : " + errorThrown); } }); </code></pre> <p><strong>Edit</strong>:</p> <p>This is the WebMethod called by UpdateProgressBar. The other WebMethod does use Session, but as you can see this one does not. They both access a dll, however, I tried testing without using the dll for the update and it did not make a difference.</p> <pre><code>[WebMethod] public static int CheckPDFProcessingProgress(// params go here) { int pagesProcessed = 1; try { OrderService _orderService = new OrderService(); pagesProcessed = _orderService.GetMailingPDFPagesProcessedProgress(PersonID); } catch (Exception ex) { // log error } return pagesProcessed; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload