pass php array to jquery with getJSON
- by robertdd
i want to pass a php aray to jQuery:
$.getimagesarr = function() {
$.getJSON('operations.php', {'operation':'getimglist'}, function(data){
var arr = new Array();
arr = data;
return arr;
});
}
var data = $.getimagesarr();
if (data){
jQuery.each(data, function(i, val) {
....
});
}
it return undefined
in php i have this:
function getimglist(){
$results = $_SESSION['files'];
echo json_encode($results);
}
it is possible?