adding two times javascript post function
Posted: 25 Nov 2019, 11:24
I`m busy for a few hours to add a function in my comment system
this comment-system post comments is without page-refresh
Only I can`t find out how to use this script two times ?
Separated I have no errors but it is not working on both....
I would like to add this new function but without any success
Hope you have any tips for me....
this comment-system post comments is without page-refresh
Only I can`t find out how to use this script two times ?
Separated I have no errors but it is not working on both....
Code: Select all
<script>
$(document).ready(function(){
$('#comment_form').on('submit', function(event){
event.preventDefault();
var form_data = $(this).serialize();
$.ajax({
url:"comment/comments/add_comment.php",
method:"POST",
data:form_data,
dataType:"JSON",
success:function(data)
{
if(data.error != '')
{
$('#comment_form')[0].reset();
$('#comment_message').html(data.error);
$('#comment_id').val('0');
load_comment();
}
}
})
});
load_comment();
function load_comment()
{
$.ajax({
url:"comment/comments/fetch_comment.php?id=<?php echo $_GET['id'];?>",
method:"POST",
success:function(data)
{
$('#display_comment').html(data);
}
})
}
$(document).on('click', '.reply', function(){
var comment_id = $(this).attr("id");
$('#comment_id').val(comment_id);
$('#comment_name').focus();
});
$(document).on('click', '.reply', function(){
var comment_id = $(this).attr("reply_to");
$('#reply_to').val(comment_id);
$('#reply_to').focus();
});
$(document).on('click', '.reply', function(){
var comment_id = $(this).attr("reply_to");
$('#comment_content').val(comment_id);
$('#comment_content').focus();
});
});
</script>
Code: Select all
<script>
$(document).ready(function(){
$('#comment_form').on('submit', function(event){
event.preventDefault();
var form_data = $(this).serialize();
$.ajax({
url:"comment/comments/add_note.php",
method:"POST",
data:form_data,
dataType:"JSON",
success:function(data)
})
}
</script>