Ajax功能:
$(document).on("click", "#barcode_check", function(){
var data = {barcode: $('#barcode').val()};
$.ajax({
url: '/scanner/submit_barcode.php',
type: 'POST',
dataType: "json",
data: data,
success: function(data){
$(".container").html(Scanner_info);
}
});
});
PHP:
$query = mysqli_query($conn, "SELECT * FROM table1 WHERE BarCode='" . $_POST['barcode'] . "'");
$return = $_POST;
if(mysqli_num_rows($query) > 0)
{
}
else
{
$barcode = mysql_real_escape_string($_POST['barcode']);
$_SESSION["barcode"] = $barcode;
$sql = "INSERT INTO table1 (BarCode)
VALUES ('$barcode')";
}
同样在开发人员工具中,网络选项卡返回状态200,文本确定 我不知道该怎么做才能修复它,并且有成功的功能。