I am working on a project that uses JavaScript (AJax) to call a php file to query a MySQL Server. I have traced the call to php and see that it is working but the AJax call never gets anything. below is my JavaScript and PHP code, could someone look at it and tell me what I am missing.
javaScript:
$(function() {
$('#members').on('input', function() {
var opt = $('option[value="'+$(this).val()+'"]');
/*getMember(opt.length ? opt.attr('id'): 0);*/
$.ajax({
url: 'data/members.php',
type: 'POST',
data: {'action':'get', 'status':opt.attr('id')},
sucess: function(data) {
alert(data);
},
error: function() {
alert("We have a problem");
}
});
});
});
php:
$action = $_POST["action"];
if ($action == "get") {
$memberID = $_POST["status"];
try {
require "../../classes/data.php";
$data = new data();
$conn = $data->connect();
$sql = "SELECT * FROM members WHERE memberID = " . $memberID;
$result = $data->query($sql);
while($row = $result->fetch_assoc()) {
$returnData = $row;
}
echo $returnData;
} catch (Exception $ex) {
}
}