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

 

Link to comment
Share on other sites

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%..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.