Wednesday 15 August 2012

c# - Progress Bar for AJAX based on server-side process -


My original idea was to create a session variable, and update it as the server-side process as it was computing all the examples of

For, if it has become 1/10 of the main task, then say 10% for the session update the variable ... Meanwhile I have a second AJAX request as long as the server-side processing is being done, this session Checking the variable is going on. However, I am now reading that session variables are not available until my server-side processing page is over.

I have also noticed that with this approach that my second ASPX server side processing is complete, which is useless because it will not provide any loading information until the processing is completed.

I have an animated loading icon right now, but I need some kind of indicators that the server is on.

Current Setup

  Function getComparison (Results) {// Results to display results from comparisons.aspx $ $ ( "#differenceSummary") HTML (results). // Overloading overlay image $ ("#Loading") Deletion Class ("Visible"); }   

Actually I dump the contents of comparisons.aspx in just one div. I looked at the UpdatePanel server control, but this does not seem to make examples useful in this situation. They use all the buttons, I need a live feed of what's happening.

If I can return anything (like 1-100 or some kind) it would be very useful.

For those people how I am doing this, I have several AJAX requests.

My first AJAX request was determined how many requests were needed (I had 700,000 DB records, I had 30,000 at one time) and the loading bar setup once the loading bar was set up After that, I repeatedly hit the same ASPX file "X" volume, for each call, I need the progress bar (a little bit of math). Once the progress bar reaches 100 percent, then I request another AJAX which resulted in the results from server side processing.

My initial code, which calls comparison.aspx, and adds it to a single device. / P>

  $ Ajax ({url: "comparisons.aspx", type: "GET", success: getComparison, error: showErrors}); // On success, display results getComparison (results) {// Results $ ("#interity Suri") to capture content from comparisons.aspx. Html (results); }   

When comparisons.aspx is loaded first, it loads an empty progress bar and also generates information based on the files I upload (this is my application Is specific). When this page loads, the amount of AJAX requests is put in Javascript.

  // How to check how many records in var numOfRecordsAtatime = 30000; // Original / Modified Record Number Original OrigNumOfRecords = parseInt ($ ("# origNumOfRecords"). Text ()); Var modNumOfRecords = parseInt ($ ("# modNumOfRecords"). Text ()); Highest number; // arithmetic to see how many AJAX calls are needed (orignumfforords & gt; modNumOfRecords) {highest = orignumforkers; } And {highest = modulationfirecord; } Var numberofCallsToMake = parseInt (Math.floor (highest number / numberoffordsettime)) + 1; // How much progress meter should be increased in var increments = (100 / numberofCallsToMake); // Total of the records in total we have full var numRecords = 0; // many times we have incremented var numIncrementsCompleted = 0; Function currentAjax () {$ ("# progress bar"). Progress Bar ({value: 1}); If (stop!) {While (numbers fully & lt; origNumOfRecords) {$. Ajax ({url: "ajaxCall.aspx? RandNo =" + Math.random (), Type: "GET", success: doAjaxCall, error: showTheError}); NumRecordsCompleted = numRecords complete + numOfRecordsAtatime; } And {break} }}}} Function doAjaxCall (results) {numIncrementsCompleted ++; Console.log (results); Var progress = (parseInt (numIncrements full * increment)); $ ("# Progress bar") Progress bar ({value: progress}); Console.log (progress); If (progress == 100) {getResults (); }}    

No comments:

Post a Comment