I'm still new to jQuery and if this isn't the proper forum, please move it to the proper forum.
I have the following jQuery function defined:
function cancel_file(id){
jQuery.ajax({
type: "POST",
url: "https://www.mysite.com/cancel.php",
data: 'id='+ id,
cache: false,
success: function(response){
(response == 1){
alert('File successfully cancelled!');
}
error: function(response){
if(response == "invalid_id"){
alert('The file ID format is invalid');
}else if(response == "no_record_found"){
alert('No file found with ID specified');
}
}
});
}
That posts the data to cancel.php via a text link to update a column in a MySQL table
<a href="#" onclick="cancel_file(12)">Cancel</a>
The file id is dynamically passed to the link and that part works so I chose 12 for simplicity.
<?php
// Get the zip id and make sure it's in a valid format
$id = $_POST['id'];
if(!ctype_digit($id)){
$response = "invalid_id";
}else{
// If validation passes proceed to queries and cancellation process
$q1 = "UPDATE `tbl_files` SET `is_invalid` = 1 WHERE `id` = '".$id."'";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_affected_rows() > 0){
$response = mysql_affected_rows();
}else{
$response = "no_record_found";
}
echo $response;
?>
$response = mysql_affected_rows(); should end up behing $response = 1 if the query is successful and that response passed back to the jQuery for alert. But the problem is nothing happens when I click the "Cancel" link. I verify that the MySQL table has a file with the ID passed to the script and the "is_invalid" column has not changed.
Thanks in advance for any advice and guidance.