I have a function that return array object from php using mysql and i want call array from ajax function using javascript, but i don't know how display array object php in javascript dinamic table or console log....
my php file:
$age = $_POST["param"]; //value ajax param
$list = BussinesLayer::getUsers($age); //load my list
//list properties ej: list->getName(), getAge(), getOcupation()->getDescription(), etc..
echo json_encode($list);
my js function:
fnListUsers: function() {
var agedata = $("#txtAge").val();
$.ajax({
type : "POST",
url : "../ControllerFile/SearchUsers.php",
data : {"param" : agedata},
dataType : 'json',
success : global.fnSuccessList,
error : function (XMLHttpRequest, textStatus, errorThrown) {
alert("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
}
});
},
fnSuccessList: function(data) {
var array = JSON.parse(data); // -> dont work Uncaught SyntaxError: Unexpected token o in JSON at position 1
var array2 = jQuery.parseJSON(data); // dont work Uncaught SyntaxError: Unexpected token < in JSON at position 0
//how display my arrayobject ?
console.log(data.getName, data.getOcupation.getDescripition);
}


dataType : 'json',this already done the job for you