Hi i search and found some info but i cant just cant set a name for this function to call it again in other function to "reload" the data.
Im a noob so i try to wrap from var form to the en in a function myfunction() {} but did not work. any suggestions?
$(document).ready(function (){
var form = $('#formcomments');
var submit = $('#comments');
// send ajax request
$.ajax({
url: '<?PHP echo $this->make_base_url("user/comments_all/".$resdata['id']."/");?>',
type: 'POST',
cache: false,
data: form.serialize(), //form serizlize data
beforeSend: function(){
// change submit button value text and disabled it
submit.val('Enviando...').attr('disabled', 'disabled');
},
success: function(data){
// Append with fadeIn see http://stackoverflow.com/a/978731
var item = $(data).hide().fadeIn(800);
$('.module').append(item);
var objDiv = document.getElementById("modulecomm");
objDiv.scrollTop = objDiv.scrollHeight;
// reset form and button
form.trigger('reset');
submit.val('Submit Comment').removeAttr('disabled');
},
error: function(e){
alert(e);
}
});
});