当我像这样手动推送参数时: aoData.push( { "name": "process", "value": "fetch" } ); 它运行良好,没有任何错误消息。
但是,现在我想在脚本顶部声明数组 tableXtraPostParams 并将这个数组的参数一一推送到 aoData
这是一段代码工作正常
var tableXtraPostParams = {
"process":"fetch",
"which":"mine"
};
$.each(tableXtraPostParams, function(n, v){
aoData.push( {
"name": n,
"value": v
} );
});
但是我在 JS 日志中收到错误消息
语法错误,无法识别的表达式:[object Object]
我在这里想念什么?
任何建议将不胜感激!
更新
我知道这个错误与我的修改有关。(因为当我删除时$.each
,我没有收到任何这样的错误)
这是Aodata在推送之前的样子
[Object { name="sEcho", value=1}, Object { name="iColumns", value=8}, Object { name="sColumns", value=""}, Object { name="iDisplayStart", value=0}, Object { name="iDisplayLength", value=25}, Object { name="mDataProp_0", value=0}, Object { name="mDataProp_1", value=1}, Object { name="mDataProp_2", value=2}, Object { name="mDataProp_3", value=3}, Object { name="mDataProp_4", value=4}, Object { name="mDataProp_5", value=5}, Object { name="mDataProp_6", value=6}, Object { name="mDataProp_7", value=7}, Object { name="sSearch", value=""}, Object { name="bRegex", value=false}, Object { name="sSearch_0", value=""}, Object { name="bRegex_0", value=false}, Object { name="bSearchable_0", value=true}, Object { name="sSearch_1", value=""}, Object { name="bRegex_1", value=false}, Object { name="bSearchable_1", value=true}, Object { name="sSearch_2", value=""}, Object { name="bRegex_2", value=false}, Object { name="bSearchable_2", value=true}, Object { name="sSearch_3", value=""}, Object { name="bRegex_3", value=false}, Object { name="bSearchable_3", value=true}, Object { name="sSearch_4", value=""}, Object { name="bRegex_4", value=false}, Object { name="bSearchable_4", value=true}, Object { name="sSearch_5", value=""}, Object { name="bRegex_5", value=false}, Object { name="bSearchable_5", value=true}, Object { name="sSearch_6", value=""}, Object { name="bRegex_6", value=false}, Object { name="bSearchable_6", value=true}, Object { name="sSearch_7", value=""}, Object { name="bRegex_7", value=false}, Object { name="bSearchable_7", value=true}, Object { name="iSortingCols", value=1}, Object { name="iSortCol_0", value=0}, Object { name="sSortDir_0", value="asc"}, Object { name="bSortable_0", value=true}, Object { name="bSortable_1", value=true}, Object { name="bSortable_2", value=true}, Object { name="bSortable_3", value=true}, Object { name="bSortable_4", value=true}, Object { name="bSortable_5", value=true}, Object { name="bSortable_6", value=true}, Object { name="bSortable_7", value=true}]
这是推后
[Object { name="sEcho", value=1}, Object { name="iColumns", value=8}, Object { name="sColumns", value=""}, Object { name="iDisplayStart", value=0}, Object { name="iDisplayLength", value=25}, Object { name="mDataProp_0", value=0}, Object { name="mDataProp_1", value=1}, Object { name="mDataProp_2", value=2}, Object { name="mDataProp_3", value=3}, Object { name="mDataProp_4", value=4}, Object { name="mDataProp_5", value=5}, Object { name="mDataProp_6", value=6}, Object { name="mDataProp_7", value=7}, Object { name="sSearch", value=""}, Object { name="bRegex", value=false}, Object { name="sSearch_0", value=""}, Object { name="bRegex_0", value=false}, Object { name="bSearchable_0", value=true}, Object { name="sSearch_1", value=""}, Object { name="bRegex_1", value=false}, Object { name="bSearchable_1", value=true}, Object { name="sSearch_2", value=""}, Object { name="bRegex_2", value=false}, Object { name="bSearchable_2", value=true}, Object { name="sSearch_3", value=""}, Object { name="bRegex_3", value=false}, Object { name="bSearchable_3", value=true}, Object { name="sSearch_4", value=""}, Object { name="bRegex_4", value=false}, Object { name="bSearchable_4", value=true}, Object { name="sSearch_5", value=""}, Object { name="bRegex_5", value=false}, Object { name="bSearchable_5", value=true}, Object { name="sSearch_6", value=""}, Object { name="bRegex_6", value=false}, Object { name="bSearchable_6", value=true}, Object { name="sSearch_7", value=""}, Object { name="bRegex_7", value=false}, Object { name="bSearchable_7", value=true}, Object { name="iSortingCols", value=1}, Object { name="iSortCol_0", value=0}, Object { name="sSortDir_0", value="asc"}, Object { name="bSortable_0", value=true}, Object { name="bSortable_1", value=true}, Object { name="bSortable_2", value=true}, Object { name="bSortable_3", value=true}, Object { name="bSortable_4", value=true}, Object { name="bSortable_5", value=true}, Object { name="bSortable_6", value=true}, Object { name="bSortable_7", value=true}, Object { name="process", value="fetch"}, Object { name="which", value="all"}]