In the following function only the ajax call works, but it gets as parameter comment an empty string even when I type in the input text.
function addComment(pid,t,m,mid,pmid){
$('#commentbuttongif').html('<img id="ajaxcommentgif" src="ajax-loader.gif" />');
document.getElementById("commentbutton").disabled = true;
var comment = $("#comment").val();
var commentcount = parseInt(document.getElementById('inputcommentcount').value) +1;
$.ajax({
type:'post',
url:'addcomment.php',
data:{pid
id,
comment:comment,
pmid
mid,
t:t},
dataType:'json',
success:function(data){
$("#newcomment").prepend($('<div id="c'+data['2']+'" class="row"><div class="col-xs-6 col-md-5 col-md-offset-2"><h4><a href="membersposts.php?x='+mid+'&m='+m+'">'+m+'</a><small> '+data['0']+'['+data['1']+']:</small></h4><h5>'+ comment+'</h5></div><div class="col-md-1"><button data-toggle="tooltip" data-placement="bottom" title="Delete" class="btn btn-default btn-xs pull-right" onclick="return deleteComment('+data['2']+','+pid+');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button></div></div><div class="row" id="h'+data['2']+'"><div class="col-xs-6 col-md-6 col-md-offset-2"><hr></div></div>').fadeIn('slow'));
document.getElementById('comment').value = '';
$("#commentcount").html('<h4>Comments ('+commentcount+')</h4><form action=""><input type="hidden" id="inputcommentcount" value="'+commentcount+'"/></form>');
document.getElementById("commentbutton").disabled = false;
$('#ajaxcommentgif').remove();
}
});
return false;
}
In the next function the ajax call doesn't work but the commands inside the response function work (so when I reload the page no changes are made).
function deleteComment(commentID,postID){
var commentcount = parseInt(document.getElementById('inputcommentcount').value) -1;//this also works
$.ajax({
type:'post',
url:'deletecomment.php',
data:{cid:commentID,
pid
ostID},
success: function(response){
$("#c"+commentID).remove();
$("#d"+commentID).remove();
$("#h"+commentID).remove();
$("#commentcount").html('<h4>Comments ('+commentcount+')</h4><form action=""><input type="hidden" id="inputcommentcount" value="'+commentcount+'"/></form>');
}
});
return false;
}
The above code has been tested locally and it works. Does it has to do with configuration settings or mime types (maybe)?
Thank you.