I've searched and cannot find an answer to this. I have an ajax that loops and waits for a variable and when it does not equal 0 I want to send the data to another script so that it can update the db and then it redirects to another URL. I've tried .post and .get and cannot get the values to update the db but the script does redirect.
function updateTrigger(){
$.ajax({
url: "json.trigger.php",
dataType: "json",
cache: false,
success: function(data) {
var scrape_type = data.scrape_type;
var account_id = data.account_id;
if(account_id != 0) {
$.post('update-pending.php', {account_id: account_id, scrape_type: scrape_type});
document.location.href="redirect.com";
}
}
});
}
Here is my update-pending.php that I am sending the variables to first before it redirects.
$account_id = $_POST['account_id'];
$scrape_type = $_POST['scrape_type'];
$stmt = $con->prepare("UPDATE triggers SET
pending='1'
WHERE account_id = '$account_id' AND scrape_type = '$scrape_type'") or die(mysql_error());
$stmt->execute();