Jump to content

updating loop data on ajax


prakash

Recommended Posts

hi,

 

How can I update loop output data on ajax.

here is the two file that I am testing

 

sampleloop.php

<?php

header("Content-Type: text/html; charset=ISO-8859-15");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

ignore_user_abort(TRUE);
$total=5;
for ($i=1; $i<=$total; $i++) {

$percentage=($i/$total)*100;
print "Sending $i of $total [$percentage%]...<div class=progress><img src=progress.jpg width=$percentage% height=20 alt=progress... title=progress...></div>";

usleep(1000000); // stop for 1 second
}
?>

 

index.php

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
<script type="text/javascript" language="javascript" src="ajaxrequest.js"></script>
<title>AJAX Test</title>
</head>
<body>
<div id="main"> <!-- all results appears dynamic within the div like right here --> </div>
<p><a href="javascript: MyAjaxRequest('main','sampleloop.php')">Click to Test Loop</a></p>
</body>
</html>

 

currently index.php is making all the output at once. But I want to display the loop result each time replacing the old one.

How can it be possible.

Link to comment
Share on other sites

  • 3 weeks later...
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.