| how can i make this javascript code refresh this div ? update div in real time after click |
sofian

msg:4330529 | 2:05 pm on Jun 24, 2011 (gmt 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");
$.post("'.uhome().'/index.php?p=jquery/comment_publish",
{message:mbox[0].value,target_id:tbox[0].value},
function(data){
cbox.html("");
$(".quick_comment_form").css("display","none");
cbox.after(data);
mbox.attr("value","");
},"html"
);
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%"> <tr> <td class="user_post_left" width="'.$avatar_box_size.'" valign="top"> '.avatar($row,$avatar_size).'</td> <td class="user_post_right" valign="top"> <strong>'.url($mu.'u/'.$row['username'], $row['fullname']).'</strong> '.$att.decode_bb(nl2br(smilecomment($row['message']))).' <div class="att_bottom">'.$comments_display.' <abbr class="timeago" title="'.date("c",$row['created']).$likes.'"></abbr></div> </td> </tr> </table> </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>'); limit_posting(0,1);
comment_insert($_POST['target_id'],$_POST['message']);// this code wich insert in datapage record_this_posting($_POST['message']); $arr = array( 'avatar'=>$client['avatar'],'message'=>stripslashes($_POST['message']),'username'=>$client['uname'],'created'=>time() ); echo comment_display($arr); // this is the Temporary post untill refresh the page
ss_update(); exit; } thank you
|
yogesh

msg:4335144 | 1:00 pm on Jul 5, 2011 (gmt 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.
$('Your_Button').click(function(){ var msg = $('msg_element_from_form').val(); $('Targetdiv').text(msg); });
|
|
|