Ext store无法得到后台传的数据

shuaiAWP 2012-07-20 07:41:43
Store里面没有数据,但是直接访问后台处理程序的话有数据的

<script type="text/javascript">
Ext.onReady(function(){
var cum = new Ext.grid.ColumnModel([
{header:'ID',dataIndex:'id'},
{header:'adValue',dataIndex:'adValue'},
{header:'adTime',dataIndex:'adTime'}
]);
var store = new Ext.data.JsonStore({ proxy:new Ext.data.HttpProxy({url:'http://192.168.0.9/showAll.cgi'}),
reader:new Ext.data.JsonReader({totalProperty:'totalProperty',root:'root'},[{name:'id'},{name:'adValue'},{name:'adTime'}])
});
//store.load();
alert(store.getCount());//这个地方显示为0
var cumgrid = new Ext.grid.GridPanel({
renderTo:'cumGrid',
store:store,
viewConfig:{
forceFit:true
},
autoHeight:true,
autoWidth:true,
cm:cum,
bbar:new Ext.PagingToolbar({
pageSize:10,
autowidth:true,
store:store,
displayInfo:true,
emptyMsg:'no record'
})
});
});
</script>




#include "sqlite3.h"
#include <stdio.h>
int main(void)
{
printf("Content-Type:text/html;charset=gb2312\n\n");
// printf("<html>\n<body>\n");
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char *sql = "select * from tempture limit 20;";
char result[1024]="{totalProperty:20,root:[";
char ** tableResult;
int nRow,nColumn;
int i,j,index;
rc = sqlite3_open("envDB",&db);
// printf("<table>\n<tr><td>ID</td><td>ADVALUE</td><td>ADTIME</td></tr>\n");
// printf("%d%d",rc,SQLITE_OK);
if(rc)
{
fprintf(stdout,"Can't opendb:%s\n ",sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
rc = sqlite3_get_table(db,sql,&tableResult,&nRow,&nColumn,&zErrMsg);
if(SQLITE_OK == rc)
{
index = nColumn;
for(i = 0;i < nRow;i++)
{
// printf("<tr>");
/* for(j =0;j < nColumn;j++)
{
printf("<td>%s</td>",tableResult[index]);
index++;
}
*/
strcat(result,"{id:");
strcat(result,tableResult[index]);
strcat(result,",");
index++;
strcat(result,"adValue:");
strcat(result,tableResult[index]);
strcat(result,",");
index++;
strcat(result,"adTime:");
strcat(result,tableResult[index]);
if((i+1) == nRow){
strcat(result,"}");
}else{
strcat(result,"},");
}
index++;
// printf("</tr>\n");
}
strcat(result,"]}");
}
sqlite3_free_table(tableResult);
sqlite3_close(db);
printf("%s",result);
// printf("</table>\n");
// printf("</body>\n");
// printf("</html>\n");
return 0;
}


直接访问http://192.168.0.9/showAll.cgi'得到的数据格式为{totalProperty:20,root:[{id:883,adValue:413 ,adTime:2012-07-08 21:20:01},{id:884,adValue:409 ,adTime:2012-07-08 21:20:01},{id:885,adValue:411 ,adTime:2012-07-08 21:20:02},{id:886,adValue:407 ,adTime:2012-07-08 21:20:02},{id:887,adValue:406 ,adTime:2012-07-08 21:20:03},{id:888,adValue:409 ,adTime:2012-07-08 21:20:03},{id:889,adValue:413 ,adTime:2012-07-08 21:20:04},{id:890,adValue:402 ,adTime:2012-07-08 21:20:04},{id:891,adValue:409 ,adTime:2012-07-08 21:20:05},{id:892,adValue:406 ,adTime:2012-07-08 21:20:05},{id:893,adValue:412 ,adTime:2012-07-08 21:20:06},{id:894,adValue:408 ,adTime:2012-07-08 21:20:06},{id:895,adValue:406 ,adTime:2012-07-08 21:20:07},{id:896,adValue:408 ,adTime:2012-07-08 21:20:07},{id:897,adValue:409 ,adTime:2012-07-08 21:20:08},{id:898,adValue:410 ,adTime:2012-07-08 21:20:08},{id:899,adValue:408 ,adTime:2012-07-08 21:20:09},{id:900,adValue:406 ,adTime:2012-07-08 21:20:09},{id:901,adValue:407 ,adTime:2012-07-08 21:20:10},{id:902,adValue:406 ,adTime:2012-07-08 21:20:10}]}
...全文
129 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuaiAWP 2012-07-21
  • 打赏
  • 举报
回复
大神在哪里?
shuaiAWP 2012-07-21
  • 打赏
  • 举报
回复
是不是我的后台是CGI程序的原因啊
shuaiAWP 2012-07-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
意思是说
要么设置store自动获取数据
要么你手动load请求获取数据
[/Quote]
store.load();也是不行的
jiery666 2012-07-20
  • 打赏
  • 举报
回复
查看json转换的格式

使用firefox firebug 查看
  • 打赏
  • 举报
回复
意思是说
要么设置store自动获取数据
要么你手动load请求获取数据
shuaiAWP 2012-07-20
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

JScript code

autoLoad: true

store.load({ callback: function(records, options, sucess){
alert(records.length);
}, scope: this });
[/Quote]
???
人生无悔 2012-07-20
  • 打赏
  • 举报
回复

autoLoad: true

store.load({ callback: function(records, options, sucess){
alert(records.length);
}, scope: this });

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧