You sir are a saint.
What gets me is I knew how to do this and when I saw your example it was a d'oh! moment. so simple yet works wonders.
For anybody interested here is my completed code.
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
- <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
- <script>
- var reports = [];
- var datadisplay = new Array();
- var parts = <?= $n ?>;
- var rowsPerPart = <?= $items_per_call ?>;
- var url = '/ajax/report_show.php';
- var data = <?= json_encode($data); ?>;
- var html = '';
- var pval = 0;
- for (var i = 0; i < parts; i++) {
- reports[i] = {
- part : i
- };
- }
- fetch(0); // Start retrieval
- console.group("Retrieving Form parts");
- console.log("Retrieving parts process started.");
- function fetch(i) {
- pval = Math.ceil(100 / parts) * i;
-
- if (i < parts) {
- $.post(url, {data:data, part:i}, function(htmlp) {
- //html = html + htmlp; // Process this response
- datadisplay.push(htmlp);
- $( "#progressbar" ).progressbar({
- value: pval
- });
- $("#percentage").html("<strong>"+pval+"</strong>% Complete");
- console.log("Fetching part "+i);
- fetch(i + 1); // Fetch next one
- }, 'html');
- }
- else if(i == parts)
- {
- console.log("Fetching part "+i);
- fetch(i + 1);
- }
- else
- {
- //All reports loaded.
- console.log("Retriving the report");
-
- console.log("The report is ours");
- $("#report-holder").html("Your report is ready, and will load shortly - please wait");
- $.get('/<?=$folder;?>/<?=$file?>', function(contents){
- $("#report-holder").html(contents);
- $("#report-loading").hide();
- });
- }
-
- console.log("Completed collecting reports.");
- console.groupEnd();
- }
- </script>
- <script type="text/javascript">
- <!--
- <?php if ($debug) { ?>
- console.group("Report Log");
- <?php
- foreach ($log as $log_string) {
- echo "console.log('" . addslashes($log_string) . "'); \r\n";
- } ?>
- console.groupEnd();
- <?php
-
- }
- ?>//-->
- </script>
There is some php in this which should be easy to work out what it is for, unfortunately to post my php script as well would give more information than I am willing about my server and site :p and I do not have time to strip it
Basic gist is it runs mysql results on an ajax request limiting the amount of rows it pulls at a time, then the ajax script ties them all together and writes a file (between 70 and 200 meg) with a progress bar then display the file when done via way of a get request to the new.
It works rather well, It was bolted on to some old developers code so not everything is done in a way that I would like but it does work.
Thanks for your input
kbwood.au without that input I would have been stuck for a lot longer on this.
TJ