[英]jQuery : update the database with all of the data from the ajax-request
[英]Adding data to jQuery-Flexigrid without ajax-request
我想节省一些不需要的请求和第一次显示表的时间,所以我想也许我可以直接设置初始数据而无需任何ajax请求。 我这样尝试过:
$('#testTable').flexAddData('[formatted json here]');
还有那个
$('#testTable').addData('[formatted json here]');
但这没有任何作用。 我可以这样做,正确的语法是什么?
我也遇到了这个问题,并花了很多时间来解决它。 就我而言,解决方案非常简单。 您只需要在flexigrid()
函数中指定dataType:“ json” flexigrid()
。 默认dataType为XML。 因此,它不想了解JSON:
$("#myTable").flexigrid({dataType : "json"});
您是否使用过eval()
?
$("#testTable").flexAddData(eval('[formatted json here]'));
或尝试
$("#testTable").flexAddData(eval('[formatted json here]')).flexReload();
希望这可以帮助
为了补充Anwar和user1635430的答案,下面是一个示例JSON代码:
{
"page": "1",
"total": "9",
"rows": [
{
"id": "1",
"cell": [
"1",
"text1",
"user1",
"date1"
]
}
]
}
该代码由Anwar完成,我从他对其他问题的回答中“偷走”了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.