You will need to return an array encoded in json form as shown below.
$array = array("a","b","c","d"); echo json_encode($array);
then you can access it in javascript by converting it back to an array / object, e.g.
var result = eval(retuned_value);
You can also move through all elements of the array using the for loop
for (var index in result){
in your code it should look something like this:
PHP code:
$array = array("a","b","c","d"); echo json_encode( $array );
jQuery script
$.ajax({ type: 'POST', url: 'processor.php', data: 'data1=testdata1&data2=testdata2&data3=testdata3', cache: false, success: function(result) { if(result){ resultObj = eval (result); alert( resultObj ); }else{ alert("error"); } } });
Abu romaΓ―ssae
source share