Skip to content

Instantly share code, notes, and snippets.

@sivagao
Created July 19, 2013 02:07
Show Gist options
  • Save sivagao/6034561 to your computer and use it in GitHub Desktop.
Save sivagao/6034561 to your computer and use it in GitHub Desktop.
<div id="loadplace<?php echo $msg_id; ?>"></div>
<div id="flash<?php echo $msg_id; ?>"></div>
<div class='panel' id="slidepanel<?php echo $msg_id; ?>">
<form action="" method="post" name="<?php echo $msg_id; ?>">
<textarea id="textboxcontent<?php echo $msg_id; ?>" ></textarea><br />
<input type="submit" value=" Comment_Submit " class="comment_submit" id="<?php echo $msg_id; ?>" />
</form>
</div>
// insertjax.php
<?php
if(isSet($_POST['textcontent']){
$textcontent = $_POST['textcontent'];
})
?>
<div class="loading_comment">
<?php echo $textcontent; ?>
</div>
$(document).ready(function(){
$('.comment_submit').click(function(){
var ele = $(this);
var id = ele.attr('id');
var text = $('#textboxcontent'+id).val();
var dataString = 'textcontent=' + text + '&com_msgid' + id;
if(text == ''){
alert('please enter some text to comment');
return;
}
$('#flash'+id).show();
$('#flash'+id).fadeIn(400).html('<img src="ajax-loading.gif" align="absmiddle"> loading.... ');
$.ajax({
'type': 'POST',
'url': 'insertjax.php',
'data': dataString,
cache: false,
success: function(html){
$('#flash'+id).hide();
$('#loadplace'+id).append(html);
}
});
return false;
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment