homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

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

Msg#: 4330527 posted 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");










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



Msg#: 4330527 posted 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.

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved