首頁  >  問答  >  主體

在模態 PHP 中提交資料後不想關閉模態

<p>我想在提交此表單後保持相同的模式</p> <p><code>generateBarcode.php</code>:</p> <pre class="brush:php;toolbar:false;"><form action="savegenarateBarcode.php?id=<?php echo $d1; ?>" method="post"> ;</pre> <p><code>savegenerateBarcode.php</code>:</p> <pre class="brush:php;toolbar:false;"><?php try { session_start(); include('../connect.php'); $d1 = $_GET['id']; $b = $_POST['serialnumber']; $sqlm = "select *from product_item where serialnumber='".$b."'"; $query = $db->prepare($sqlm); $user_array = $query ->execute(); }</pre> <p>提交此表單後如何保持 <code>generateBarcode.php(modal)</code> 不變? </p>
P粉940538947P粉940538947432 天前491

全部回覆(1)我來回復

  • P粉222320176

    P粉2223201762023-09-05 11:57:39

    I think you should use ajax because the form submit method reload the page.

    var id = '<?php echo $d1; ?>';
    $("#submit").click(function(){
            $.ajax({
                type: 'GET',
                url: "savegenarateBarcode.php",
                data:`id=${id}`
                success:function(data){
                 alert(data);
                }
            });
        return false;
        });

    回覆
    0
  • 取消回覆