2010-10-21 201 views
0

如何从json字符串获取返回值?jqgrid:从json数据获取返回值

例如,在下面的代码中,如何解析和读取变量searchxx

从PHP:

$responce->page = $page; 
$responce->total = $total_pages; 
$responce->records = $BC->tot_count; 
**$responce->searchxx = $sSchWhere; 
$responce->order = $sOrder;** 

while ($data) ...... 

echo json_encode($responce); 

从HTML(萤火虫):

"page":"1","total":2,"records":"26",**"searchxx":"T0.NAME=pluto"** ,"order":"T0.NAME desc","rows":[{"id":"63025c7a-12ad-102c-bd62-005056801340","account_id":"c30c7934-e0f3-102b-8fd4-005056801340","actions":"","edtNAME":"Rossi Mario","edtACCOUNT_NAME":"<a href=\#\">Rossi Mario<\/a>","edtAREA":"DEMO","edtSTATUS":"Aperta","edtPRIORITY" ......etc. 

我有这样的代码:

jQuery("#list2").navGrid('#pager2'{edit:false,add:false,del:false,search:false,refresh:false}) 
     .navButtonAdd('#pager2',{ 
     caption:"View Condition Where",  
     buttonicon:"ui-icon",  
     onClickButton: function(){ 

      alert($("#list2").getGridParam('searchxx')); **//Should output NULL** 
      },  position:"last" }); 

如何从jsondata获得返回值searchxx

回答

1

转换JSON字符串到数组使用json_decode()

例子:

$array = json_decode($your_json_string); 
echo $array['searchxx']; // Should output "T0.NAME=pluto"