0👍
You can defer execution of window.location.assign()
until after the post completes by using a callback in $.post
:
$.post("scanquery.php", {qr: content}, () => {
window.location.assign("scanquery.php");
});
I think you have a mismatch in your payload types. $.post is formatting your object as JSON, and $_POST is not made available for JSON posts.
This source (https://davidwalsh.name/php-json) notes how to process incoming data as JSON:
# Get JSON as a string
$json_str = file_get_contents('php://input');
# Get as an object
$json_obj = json_decode($json_str);
Someone more of an expert on PHP can correct me on this part.
Source:stackexchange.com