PDA

View Full Version : About define a JsonStore issue, can not assignment for store?Help!



yagami123551
23 May 2016, 12:58 AM
Code:

var store = new Ext.data.JsonStore({
proxy : new Ext.data.HttpProxy({
url: 'NcServlet?methodName=getNcipList',
}),
reader : new Ext.data.JsonReader({
totalProperty : 'count',
root : 'nc'
})
,fields : [{name:"ncname", type:"string"} ,{name:"ncip", type:"string"}]
});

store.load();


My json data is:

{"count":1,"nc":[{"ncname":"nc_0","ncip":"192.168.0.52"}]}


the question is i can not assignment for store,
the request can be sended to server,server can return json data to javascript,
I guess the issue is happended to extjs code,please help!
my extjs version is 3.3.1

Gary Schlosberg
23 May 2016, 5:33 AM
Are you seeing an error in the console?

yagami123551
23 May 2016, 6:26 PM
console doesn't output any error,
i post my server code?Is there a problem with my server code?


protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

try{
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String method = request.getParameter("methodName");
String ret = "";
if(method.equals("getNcipList")){
ret = new WsClient().sendREP("getNcipList", "").toString();
//ret = {"count":1,"nc":[{"ncname":"nc_0","ncip":"192.168.0.52"}]}
}
out.print(ret);
}catch(Exception e){
e.printStackTrace();
}
}

yagami123551
23 May 2016, 6:31 PM
Are you seeing an error in the console?

console doesn't output any error,
i post my server code?Is there a problem with my server code?



protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

try{
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String method = request.getParameter("methodName");
String ret = "";
if(method.equals("getNcipList")){
ret = new WsClient().sendREP("getNcipList", "").toString();
//ret = {"count":1,"nc":[{"ncname":"nc_0","ncip":"192.168.0.52"}]}
}
out.print(ret);
}catch(Exception e){
e.printStackTrace();
}
}