0 レビュー
0 回答
javascript-複数のSQL挿入がDATABASETABLEで発生します
load_post(); // It will execute the function named itself ..in this case no error on inserting record works normally and fine together with the function
function load_post(){
$('#load-post-here').html("<div id='post-loader'><img src='./resources/images/loader.gif' /></div>");
$.post("./php/classroom/load_posts.php",function(data){
$('#load-post-here').html(data);
delete_option();
like(); // Like function here works normally together with comment() function
comment();
delete_comment();
});
}
setInterval(function(){
check_new_post();
}, 1000);
function check_new_post(){
$.post("./php/classroom/check_new_post.php",function(data){
$('#load-post-here').prepend($(data).hide().slideDown(1000));
delete_option();
like(); //this where happens the error, it insert multiple records of the same data in auto increment id in record, which is normal to increment, it should be a single record per like hit, the error then was in insert multiple record which is the anomaly
//comment(); ..together with this comment() function is also inserting multiple records in a single click in same data insert
//delete_comment();
});
}
function like(){
$('a.like-link').on('click',function(){
var post_id = $(this).attr('post_id');
var check = $(this).html();
//alert(check);
if (check=="Like") {
$.post("./php/classroom/like.php",{"post_id":post_id},function(response){
//alert(response);
$("a.like-link[post_id="+ post_id +"]").html("Unlike");
});
}
if (check=="Unlike") {
$.post("./php/classroom/unlike.php",{"post_id":post_id},function(response){
//alert(response);
$("a.like-link[post_id="+ post_id +"]").html("Like");
});
}
});
}
例は、「いいね!」ボタンを押したときです。データベースからレコードをチェックすると、1回のクリックで複数のレコードが表示されます。 p>
NEW設定された間隔によるものだと思いました。どう思いますか? load_post()は完全に機能しますが、複数の挿入が発生する間隔で新しいpost()を確認してください
1000から100の間隔を変更すると、より多くの挿入が発生します..提案
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。