I am trying to fill a html table with an array. The function is in php and when I call it, without ajax, but just with php it works fine but as soon as I try calling it using ajax, it returns an empty array
function getAJAX(){
var token = window.token;
$.ajax({ url: 'functions.php',
data: {action: 'openSales', access: token}
type: 'post',
success: function(output) {
document.getElementById('OpenSales').innerHTML = '';
var output = jQuery.parseJSON(output);
makeTable($('#OpenSales'),output,'overdueSales');
}
});
}
The makeTable function does work when called outside the ajax function so that is not the problem, the php code is
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
$token = $_POST['access'];
switch($action) {
case 'openSales' : echo json_encode(getOverdueSales($token)); break;
case 'blah' : blah();break;
}
}
Anyone see what I am doing wrong here?