updated: i use this:
$.getimagesarr = function(operation) {
return $.ajax({
type: 'POST',
url: 'operations.php',
data: {'operation':operation},
async: false
}).responseText
}
var jsonstring = $.getimagesarr('getimg');
var data = (new Function("return " + jsonstring))()
if (data){
....
}
old: 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?