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
https://forums.phpfreaks.com/topic/73353-updating-loop-data-on-ajax/
Share on other sites

  • 3 weeks later...

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.