Monday, 12 August 2013

500 internal server error when using ajax

500 internal server error when using ajax

I am receiving a 500 internal server error when making an ajax call.
Here is the javascript/jquery that makes the call:
$.ajax({url: 'ServicesAjaxHandler.php',
data: {action: 'add'},
type: 'post',
success: function(output) {
alert(output);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(xhr.responseText);
alert(thrownError);
}
});
And here is the php file being called:
<?php
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
switch($action) {
case 'add' : add($_POST);break;
}
}
public function add($data) {
return 'test';
}
?>
xhr.responseText returns nothing.
Is there an issue with my PHP code that is causing this error?

No comments:

Post a Comment