短的
得到
Syntax error, unrecognized expression: [object Object] @ jquery.js:4267
这是jQ的一段代码
Sizzle.error = function( msg ) {
throw new Error( "Syntax error, unrecognized expression: " + msg ); // Line 4267
};
详细的
我已经预先声明了数组aoData
。该数组由 Datatables 创建,我无法控制数组结构。
当我像这样手动推送参数时:
aoData.push( { "name": "process", "value": "fetch" } );
它运行良好,没有任何错误消息。
但问题是,当我尝试tableXtraPostParams
在脚本顶部声明数组并将该数组的参数一一推送到aoData
中时,它仍然可以正常工作,但是收到的奇怪错误消息不是来自我的代码,而是来自 jQuery。
Syntax error, unrecognized expression: [object Object] @ jquery.js:4267
这是一段代码:(当我删除$.each
循环时,错误消息消失)
var tableXtraPostParams = {
"process":"fetch",
"which":"mine"
};
$.each(tableXtraPostParams, function(n, v){
aoData.push( {
"name": n,
"value": v
} );
});
这是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"}]
我试图解决的问题
- 我下载了 jQ 1.7.2(开发版)并替换为缩小版 1.7.2。没有成功!
- 我试着写
.
for( var p in tableXtraPostParams ) {
aoData.push( {
"name": p,
"value": tableXtraPostParams[p]
} );
}
而不是 $.each。没有成功!
我在这里想念什么?我真的不知道,当我尝试从 $.each 内部推送时,为什么这条错误消息会出现在 Firefox 日志中,并且代码仍然可以正常工作。
任何建议将不胜感激!
笔记
这是一一版本(没有 $.each):datatables.net/examples/server_side/custom_vars.html