Jump to content

How can i display a page thats still loading with JQuery's load()?


robs99

Recommended Posts

Hello,

ive got a slight problem. I'm trying to load a php file with jquery using load() to write entries to a mysql database. I want to keep track of the progress and update a progress bar while the entries are being written.

The problem is that all the javascript code inside the php file im loading wont be executed until the file is completely loaded (after all the entries have been written to the db).

Is there a way to change the load() function to display the content while its loading and not wait until its finished?

I hope you can help me out :)

Thanks in advance

Rob

 

i cant find the edit button so im going to make another reply..

here is a code example to make it easier to understand:

<div id="progressbar"></div>
$('#progressbar').progressbar({value: 0});
$('#divAjax').load('addtomysql.php');

 

 

addtomysql.php:

for ($i=1;$i<=5;$i++) {
mysql_query("INSERT INTO test (something) VALUES ('bla')");
$percentage = $i / 5 * 100;
echo '<script type="text/javascript">
$('#progressbar').progressbar('option', 'value', " . $percentage . ");
</script>';
}

 

 

since the addtomysql.php file is loaded once its completed it just updates the progressbar to 100%..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.