2013-09-30 172 views
0

這裏是我的JSON響應爲「沒有找到記錄」 reply.When我嘗試檢查「ERRORMSG」或「響應」它不是propely working.Here我 JSON響應JSON響應處理

{ 
"showItems" : 
    [ 
    { 
    "errorMsg" : "NoRecordsFound", 
    "response" : "failed" 
    } 
    ] 
} 

條件cheking

success: function (response) 
{ 
    var respObj = Ext.JSON.decode(response.responseText); 
    alert(respObj[0].response);//here it does not retutning anyting 
    if(respObj[0].response=="Success") 
    { 
     Ext.getCmp('itemList').setData(respObj.showItems); 
    } 
    if(respObj[0].response=="failed") 
    { 
     Ext.Msg.alert("Alert!","No records found!"); 
    } 
} 

如何檢查的條件?請幫我解決這個

回答

1
Ext.JSON.decode(response.responseText) will return 

enter image description here

你應該訪問響應這樣

respObj.showItems[0].response 

respObj是Object

showItems是數組

響應& errorMsg是showItems數組中第一項的屬性。

嘗試

success: function (response) 
{ 
    var respObj = Ext.JSON.decode(response.responseText); 
    var response= respObj.showItems[0].response; 
    alert(response); 
    if(response=="Success") 
    { 
     Ext.getCmp('itemList').setData(respObj.showItems); 
    } 
    if(response=="failed") 
    { 
     Ext.Msg.alert("Alert!","No records found!"); 
    } 
} 
+0

感謝名單及其工作 – Fazil