2010-10-21 199 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"