I'm trying to use form submit with jquery without a page refresh as demonstrated in this tutorial: submite a form without page refresh using jquery demo
It uses the $.ajax function to post the values, which I've included below:
$.ajax({
type: "POST",
url: update.php,
data: dataString, // dataString's value is 'id=5'
success: function() { ... };
});
which is working for me in swapping the wrapper that I have around the form...
HOWEVER, when I try to process the dataString in data in update.php (which I'm using to update an entry from a MySQL DB), I get nothing.
in update.php,
I have...
<?php
require_once('DB.php');
$dbh = DB:: connect(...);
if (DB::iserror($dbh)) {
die(...);
}
$aid = isset($_POST['id']);
// 'id' column datatype is INT
$sql = "UPDATE [table] SET x = 'blah' WHERE id = ".aid.";";
$result = $dbh->query($sql);
--regardless, the database doesn't update. Does anyone see a glaring issue that I don't (note: I'm new to jquery and AJAX etc altogether) see? I tried using Safari's developer menu to track what's wrong, but I can't figure out how to track the update.php component. Also, I'm not sure how to apply print_r or var_dump to the variables in the update.php page because I'm posting to it separately from the page that's calling the function in my .js file. Am I approaching this incorrectly? Any assistance would be appreciate--Thanks in advance!