Quote:
Originally Posted by jfreak53
Yeah, but you can only have X amount of max async calls in a browser at one time, I would max way out with the 625 calls that it makes to the script. Plus there's no way to know if their are 625 records or less or more.
|
you could only do one call at a time, you never need more than a dozen hanging out there at once...
you trigger the next call or batch of calls upon the arrival of a call.
i'm not sure what your server spits out, but i faced a related challenge doing a CMS content dump, from a mysql db. i used LIMIT to ask for 100 rows at a time, range specified in the url. if the result set came back with 100 entries, i incremented the range by 100. if it had fewer than 100 rows, that set was complete and i invoked the collector callback to save the collated results to a file.
to get started, i would break your code into more re-usable functions. get the logic out of the loop. once you get everything broken up, it will be much easier to start making it async.
in particular,
Code:
while(num1 <= num4) {
could be
Code:
function next(num1, num4) {
if(num1>=num4){ return;}
...
also, i would look at the sql, you should be able to combine a lot of those queries before they are served. use joins to create a wider table of data to avoid repeated calls.
also, this line:
Code:
z = j.parseJSON(ajax('countPolCar', s.params.curdate, ''));
can be moved to before the while loop (or function), which saves an IO every loop.