function callCrudAction(action,id) { $(".btnAddAction").hide(); $("#loaderIcon").show(); var queryString; switch(action) { case "add": //get closest comment list box var selector = $(id).closest(".comment-list-box") //get text area and post id values var txtmessage = selector.find(".txtmessage").val() var postid = selector.find(".postid").val() var uname= selector.find(".uname").val() var uemail= selector.find(".uemail").val() console.log(txtmessage + " --" + postid + " --" + uname + " --" + uemail) queryString = 'action=' + action+ '&txtmessage=' + txtmessage+'&postid='+ postid+'&uname='+uname+'&uemail='+uemail; break; } jQuery.ajax({ url: "../templates/crud_cm.php", data:queryString, type: "POST", success:function(data){ switch(action) { case "add": $(data).insertAfter(".message-wrap:first"); //selector.find(".txtmessage").hide() //selector.find(".btnAddAction").hide() break; } $(".txtmessage").val(''); $(".uname").val(''); $(".uemail").val(''); $("#loaderIcon").hide(); $(".btnAddAction").show(); $(".new_comment_area").hide(); }, error:function (){} }); } // reply function callCrudActionr(action,id) { $(".loaderIconn").show(); var queryString; switch(action) { case "addr": //get closest comment list box var selector = $(id).closest(".comment-list-boxr") //get text area and post id values var txtmessager = selector.find(".txtmessager").val() var postidr = selector.find(".postidr").val() var postm = selector.find(".postm").val() var unamer= selector.find(".unamer").val() var uemailr= selector.find(".uemailr").val() queryString = 'action=' + action+ '&txtmessager=' + txtmessager+'&postidr='+ postidr+'&postm='+ postm+'&unamer='+ unamer+'&uemailr='+ uemailr; break; } jQuery.ajax({ url: "../templates/crud_cmr.php", data:queryString, type: "POST", success:function(data){ switch(action) { case "addr": //selector.append(data); $(data).insertAfter(".message-wrapcm-"+ postidr +":first"); selector.find(".txtmessager").hide() selector.find(".unamer").hide() selector.find(".uemailr").hide() selector.find(".btnAddActionr").hide() selector.find(".btnAddActionclose").hide() $(this).closest(".comment-list-boxr").find(".anor").hide(); selector.find(".anor").hide() break; } $(".txtmessager").val(''); $("#loaderIconn").hide(); }, error:function (){} }); } // main comments show $(document).ready(function(){ $(".add-main").click(function(){ $(this).closest(".main-comment-list-box").find(".main-comments").show(); }); }); $(document).ready(function(){ $(".add_new_comment").click(function(){ $(".new_comment_area").show(); }); }); // Hide $(document).ready(function(){ $(".hide-main").click(function(){ $(this).closest(".main-comment-list-box").find(".main-comments").hide(); }); }); // main comments // reply $(document).ready(function(){ $(".add_comment").click(function(){ $(this).closest(".comment-list-boxr").find(".txtmessager").show(); $(this).closest(".comment-list-boxr").find(".unamer").show(); $(this).closest(".comment-list-boxr").find(".uemailr").show(); $(this).closest(".comment-list-boxr").find(".anor").show(); $(this).closest(".comment-list-boxr").find(".btnAddActionr").show(); $(this).closest(".comment-list-boxr").find(".btnAddActionclose").show(); }); }); // reply $(document).ready(function(){ $(".btnAddActionclose").click(function(){ $(this).closest(".comment-list-boxr").find(".txtmessager").hide(); $(this).closest(".comment-list-boxr").find(".unamer").hide(); $(this).closest(".comment-list-boxr").find(".uemailr").hide(); $(this).closest(".comment-list-boxr").find(".anor").hide(); $(this).closest(".comment-list-boxr").find(".btnAddActionr").hide(); $(this).closest(".comment-list-boxr").find(".btnAddActionclose").hide(); }); }); $(document).ready(function(){ $(".ano").click(function(){ $(".uname").val(''); $(".uemail").val(''); $(this).closest(".comment-list-box").find(".blank").show(); }); }); $(document).ready(function(){ $(".anor").click(function(){ $(".unamer").val(''); $(".uemailr").val(''); $(this).closest(".comment-list-boxr").find(".blankr").show(); }); });