js:
$.ajax({
type: "POST",
url: 'post.php',
data: serialNumber + "&getSerialNumber=" + 1,
dataType: 'json',
success: function(data, textStatus, jqXHR) {
console.log("SUCCESS");
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("ERROR");
}
});
php:
if($product->GetSerial($serial)) {
$productInfo = $product->GetSerial($serial)->first();
header('Content-Type: application/json', true, 200);
die(json_encode(["error"=> false, "message"=> "Successfully got serial number"]));
} else {
header('Content-Type: application/json', true, 400);
die(json_encode(["error"=> true, "message"=> "failed to get serial number"]));
}
header('Content-Type: application/json', true, 200);