Javascript 每个文件中的代码都在工作,但记录条目在每个表中重复两次

Javascript 每个文件中的代码都在工作,但记录条目在每个表中重复两次,javascript,php,twitter-bootstrap-3,jqbootstrapvalidation,Javascript,Php,Twitter Bootstrap 3,Jqbootstrapvalidation,验证过程是正确的,数据条目也在发生,但在提交表单时,记录会在每个表中插入两次 lib_book_reg.php php代码 尝试在单击事件后禁用按钮。 尝试添加您可以在超时或ajax成功后启用它 $(this).attr('disabled',true); 之后 更新 这也可能是因为为该按钮分配了两次单击事件 因此,在分配之前,只需解除旧的单击事件的绑定并分配新的 示例代码 $('#entry_sub_btn').off('click').on('click',function(e){ 检查

验证过程是正确的,数据条目也在发生,但在提交表单时,记录会在每个表中插入两次

lib_book_reg.php php代码


尝试在单击事件后禁用按钮。 尝试添加您可以在超时或ajax成功后启用它

$(this).attr('disabled',true);
之后

更新

这也可能是因为为该按钮分配了两次单击事件

因此,在分配之前,只需解除旧的单击事件的绑定并分配新的

示例代码

$('#entry_sub_btn').off('click').on('click',function(e){

检查单击事件是否分配了两次。请尝试我在答案中输入的更新代码。
<?php
    session_start();
    if($_SESSION['user'] != "Library")
    {
        echo "Only Librarian is authorized to make an entry!";
    exit();
    }
    require 'config.php';

    // $eid = $_POST['eid'];
    $entry_isbn = $_POST['entry_isbn'];
    $entry_subject = $_POST['entry_subject'];


    $stmt = $dbh->prepare("INSERT INTO lib_book_reg(l_book_isbn, l_book_subject)    VALUES(?,?)");
    $stmt->execute(array($entry_isbn, $entry_subject));

    $stmt1 = $dbh->prepare("INSERT INTO l_book_opr_db(l_book_isbn, l_book_subject)  VALUES(?,?)");
    $stmt1->execute(array($entry_isbn, $entry_subject));

    echo "Registered Successfully";
    ?>
$(this).attr('disabled',true);
$('#entry_sub_btn').on('click',function(e){
$('#entry_sub_btn').off('click').on('click',function(e){