Zde je příklad toho, jak byste měli provádět požadavky Ajax s jQuery/PHP/MySQL
JS
var postData = {
first_name: 'Foo',
last_name: 'Bar',
phone: '1-555-432-1234'
};
$.post('path/to/ajax/url.php', postData)
.done(function(response) {
alert("Data Loaded: " + response);
});
PHP
// Connect to MySQL
$dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
// We want do some validation on the data so we can make a function called
// `validate()` if you want.
$data = validate($_POST);
$stmt = $dbh->('INSERT INTO my_table (first_name, last_name, phone)
VALUES (:first_name, :last_name, :phone)');
$stmt->execute($data);