Skip to content
Advertisement

Do not want to close modal after submit data in modal PHP

I want to stay same modal after submitting this form

genarateBarcode.php:

<form action="savegenarateBarcode.php?id=<?php echo $d1; ?>" method="post">

savegenarateBarcode.php:

<?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();


how can I stay same genarateBarcode.php(modal) after submiting this form?

Advertisement

Answer

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;
    });
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement