I am working on a gallery with comment system. It means when I click on next and previous then the new pic with its comments are loaded. But the problem is that I am using a commentbox in which when I open a pic and submit comment for it, it submit the same comment only one time (the way it should work), but when I click on next pic (pic 2) and submit comment for it, the comment is submitted two times (instead of one), and the third pic three times and so on. Here is my jquery code hope someone help me with this
$('body').on('keyup', '#stg_cmtarea', function(e) {
if (e.which == 13 && $.trim(this.value).length) {
var picId = $(".gal_cmt_cnt_info").attr('gdata');
var userId = $("#mipicview-overlay-content").attr('vwid');
var comment = $("#stg_cmtarea").val();
var dataString = 'comment=' + comment + '&pic_id=' + picId + '&user_id=' + userId;
if ($.trim(comment).length == 0) {
alert("Please Enter Comment Text");
}
else {
$.ajax({
type: "POST",
url: "modules/gallery/piccomment_ajax.php",
data: dataString,
cache: false,
success: function(html) {
alert(html);
}
});
}
return false;
}
});