Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

how can i make this javascript code refresh this div ?

update div in real time after click

2:05 pm on Jun 24, 2011 (gmt 0)

New User

5+ Year Member

joined:June 24, 2011
posts: 2
votes: 0

hi every body
please help me to refresh my div's content :

the codes :
javascript : -

$(".commentsubmit").click(function() {
if ($(this).prev()[0].value != "") {
var thiscomment = $(this).parents(".quick_comment_form");
var cbox = thiscomment.next().next();

var mbox = thiscomment.find(".commentmessage");

var tbox = thiscomment.next();

cbox.html("<img src=\"'.uhome().'/files/loading.gif\" /> submitting");










return false;



html :-

<input type="button" value=" comment " class="fbutton commentsubmit" />
// this the button wen i click on it i want to refresh the div .

the div :-

<div class="user_post_1">
<table width="100%">
<td class="user_post_left" width="'.$avatar_box_size.'" valign="top">
<td class="user_post_right" valign="top">
<strong>'.url($mu.'u/'.$row['username'], $row['fullname']).'</strong>
<div class="att_bottom">'.$comments_display.'
<abbr class="timeago" title="'.date("c",$row['created']).$likes.'"></abbr></div>

informations :
it works on my site like this :
the button use the javascript to post a Temporary message on the page wall (in the same time insert the contents in the database ) ,
but this message showing Different and not from the database , but after i refresh all the page it shows all the contents from the database like i want .
but realy i want to refresh this div wen post the message not after refresh the
wall page . and please i dont want refresh by time , just if click .
wich code and were to add to refresh the div ?
thank you verry much all you .

here is the jquery code :

function comment_publish() {
global $client, $config;
if (!$client['id']) die('<div class="ferror">login please</div>');
if ( !preg_match("/^[0-9a-z]+$/i",$_POST['target_id']) ) die('no target id');
if (strlen($_POST['message'])<2) die('<div class="ferror">message is too short</div>');

comment_insert($_POST['target_id'],$_POST['message']);// this code wich insert in datapage
$arr = array(
echo comment_display($arr); // this is the Temporary post untill refresh the page


thank you
1:00 pm on July 5, 2011 (gmt 0)

New User

5+ Year Member

joined:Feb 2, 2011
posts: 12
votes: 0

I did not understand clearly what you want to do here. Do you want to refresh the div with a message and insert the same message in database?

If that's the case, this jquery code should work fine.

var msg = $('msg_element_from_form').val();

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members