Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh only a div in php [closed]

Tags:

html

ajax

php

I have a chat box that i want to update :-) But I want only to refresh the div and not the hole page... Can someone help me??

Code:

<div align="right" id="chat">
<?php
include 'Chat.php';

?>
</div>
like image 686
user1241123 Avatar asked Mar 13 '12 20:03

user1241123


2 Answers

You can't do it with a server side script like php

However, Using jQuery, when you need to update the div. Simply use

$("#chat").load("Chat.php");

For an example, make a request to the server when a user finishes typing on a textbox, and load the recent chat text.

$("#textbox").change(function() {
    $("#chat").load("Chat.php");
});
like image 154
Starx Avatar answered Sep 21 '22 09:09

Starx


checkout this one. Its easy to implement and pretty useful.

http://www.9lessons.info/2009/07/auto-load-refresh-every-10-seconds-with.html

also see this

Auto-refreshing div with jQuery - setTimeout or another method?

Good luck..

like image 35
Milap Avatar answered Sep 23 '22 09:09

Milap