Here in an array i have in javascript, this works great!
_rowData: [
{ name: "Most Recent", view: "recentView" },
{ name: "Most Popular", view: "popularView" },
{ name: "Staff Picks", view: "staffView" }
],
How could i generate this array from a php script? I want to use AJAX to get the results returned by the php.
Thanks!
EDIT
How do i manipulate this php returned json, back into _rowData ?
Try to use JSON. PHP function json_encode()
EDIT:
Code example(server side – PHP):
Client side(javascript). Note: YUI is used to show client-side handling:
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.
Hope, it’ll help you.