PDA

View Full Version : how is the output format of php response to ajax request of grid



tianhao
15 Aug 2012, 9:20 PM
hi
here is grid which data store is ajax. when i use static text file, it works fine. here is the code of url definition:
url: mytext.txt
and the content is:
{
"items": [
{
"duty_id": 1,
"ptype": "MEETING",
"begin_date":'2012-04-05',
"end_date":'2012-04-06',
"pdesc":"desc1"
},
{
"duty_id": 2,
"ptype": "VOCATION",
"begin_date":'2010-04-05',
"end_date":'2010-04-06',
"pdesc":"desc2"
},
{
"duty_id": 3,
"ptype": "MEETING",
"begin_date":'2011-04-05',
"end_date":'2011-04-06',
"pdesc":"desc3"
},
]
}
but when i use php to generate the same text, the web page is always loading.
what is the output format of php response ?

tianhao
15 Aug 2012, 9:30 PM
sorry i made a mistake. response data must include column name like this:
"duty_id": 3 not only 3.

scottmartin
16 Aug 2012, 9:28 AM
include success: true in your result json



$return = array(
'success' => TRUE,
'data' => $data
);

$return = json_encode($return);


Scott.