I am using this script for updating my div every x second.
<script type="text/javascript" src="jquery.js"></script>
<script>
var auto_refresh = setInterval(
function ()
{
$('chatbox').load('chat.php').fadein('slow')
}, 1000); // refresh every 1000 milliseconds
</script>
I used it to update the div of chat,But, When I viewed my page, It duplicated my whole page and showed it at the end of page, Nothing was working, The submission form and div were duplicated and Computer Usage went to 99%.
Anything wrong in that?
If “form” is a div id, it needs to be
$('#form')not$('form'). The latter will load chat.php into every form element on the page.Also, be sure that chat.php is ONLY printing the form element you need, and not the entire page. jQuery offers functionality to parse just what you need,
$('#form').load('form.php #form');.Keep in mind that the server is still sending the entire page to the client which is inefficient. If this is your issue, consider modifying your php to send just JSON (or similar) data, and format it as you need client side.