Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For those wondering how I ended up doing this, I ended up doing several AJAX requests.</p> <p>My first AJAX request determined how many requests were going to need to be made (I had 700,000 DB records, I did 30,000 at a time) and setup the loading bar. Once the loading bar was setup, I hit the same ASPX file "X" amount of times, for each call that's made, I update the progress bar (Requires a bit of math). Once the progress bar reaches 100 percent, I do another AJAX request to grab the result from the server side processing that I did.</p> <p>My initial code that calls comparison.aspx, and appends it to a div.</p> <pre><code>$.ajax({ url: "comparisons.aspx", type: "GET", success: getComparison, error: showErrors }); //On Success, show results function getComparison(result) { //grabs content from comparisons.aspx to show results $("#differenceSummary").html(result); } </code></pre> <p>When comparisons.aspx first loads, it loads an empty progress bar and also generates info based on files I've uploaded (This is specific to my application). When this page is loaded, the amount of AJAX Requests is put in the javascript.</p> <pre><code> //how many records to check at a time var numOfRecordsAtATime = 30000; //number of original/modified records var origNumOfRecords = parseInt($("#origNumOfRecords").text()); var modNumOfRecords = parseInt($("#modNumOfRecords").text()); var highestNum; //arithmetic to see how many AJAX calls are necessary if (origNumOfRecords &gt; modNumOfRecords) { highestNum = origNumOfRecords; } else { highestNum = modNumOfRecords; } var numberofCallsToMake = parseInt(Math.floor(highestNum / numOfRecordsAtATime)) + 1; //How much the progress meter should increase at a time var increments = (100 / numberofCallsToMake); //number of records in total we've completed var numRecordsCompleted = 0; //number of times we've incremented var numIncrementsCompleted = 0; function startAjax() { $("#progressbar").progressbar({ value: 1 }); if (!halt) { while (true) { if (numRecordsCompleted &lt; origNumOfRecords) { $.ajax({ url: "ajaxCall.aspx?randNo=" + Math.random(), type: "GET", success: doAjaxCall, error: showTheError }); numRecordsCompleted = numRecordsCompleted + numOfRecordsAtATime; } else { break; } } } } function doAjaxCall(result) { numIncrementsCompleted++; console.log(result); var progress = (parseInt(numIncrementsCompleted * increments)); $("#progressbar").progressbar({ value: progress }); console.log(progress); if (progress == 100) { getResults(); } } </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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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