JSON kullanmaya çalışın. PHP işlevi json_encode()
EDIT:
Code example(server side - PHP):
// data handling
$arrayToSend = array(array('name'=>'Most Recent', 'view'=>'recentView'),
array('name'=>'Most Popular', 'view'=>'popularView'),
array('name'=>'Staff Picks', 'view'=>'staffView'));
echo json_encode($arrayToSend);
Client side(javascript). Not: YUI istemci tarafında işleme göstermek için kullanılır:
var callback = {success: function(req) {
selectItems(req.responseText);
}
};
YAHOO.util.Connect.asyncRequest('GET',url + '?param=1',callback);
function selectItems(resp) {
var result = eval('(' + resp + ')');
for (var i=0; i < result.length; i++) {
// Do whatever you want with array result :)
}
}
Comments: 1) In PHP script you have to make response, which outputs your array, previously encoded to JSON format.
2) Except YUI you can also use any appropriate JavaScript library to generate AJAX request(i.e. JQuery, Prototype). In my case, I used function eval() to make array from JSON response.
Sana yardım edeceğim, umarım.