I am working with XAMPP and PHPStorm v9, running locally, a simple application that does an AJAX callback.
My server handler for the AJAX request is showing an empty $_POST array and I have no idea why. Before I take all of this code and run on a different server, to eliminate the platform as the issue, does anyone see why the $_POST array would be empty? Any suggestions? Thanks
The XHR pane, shows the post executed.
The JS
if (valid) {
var queryStr = 'fName=' + firstName.val() + '&lName=' + lastName.val() + '&email=' + email.val() + '&phone=' + phone.val();
var f = firstName.val();
var l = lastName.val();
var e = email.val();
var p = phone.val();
$.ajax({
type: "POST",
url: '/ACS567-Projects/addContact.php',
data: {
fName: f,
lName: l,
email: e,
phone: p
},
dataType: 'html',
success: OnAddSuccess,
error: OnAddFailure,
timeout: 60000
});
}
The PHP handler
<?php
if(isset($_POST['fName'])) {
$firstName = $_POST['fName'];
$lastName = $_POST['lName'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$addressBook->addContact($firstName,$lastName,$email,$phone);
echo "<b>success</b>";
exit();
}
echo "<b>failure</b>";
exit();