Strange jQuery error message

Short

Getting

Syntax error, unrecognized expression: [object Object] @ jquery.js:4267 

Here is a snippet of code from jQ

 Sizzle.error = function( msg ) { throw new Error( "Syntax error, unrecognized expression: " + msg ); // Line 4267 }; 

Detailed

I have a previously declared aoData array. This array is created by Datatables, and I don't have a contorl over array structure.

When I manually click the parameters one by one, for example:

aoData.push( { "name": "process", "value": "fetch" } );

It works well without error message.

But the problem is that when I try to declare an array of tableXtraPostParams at the top of the script and push one after another, this array of params in aoData , it still works fine, but getting a strange error message is not from my code, but from jQuery.

 Syntax error, unrecognized expression: [object Object] @ jquery.js:4267 

Here is the code snippet: (When I delete the $.each , the error message disappears)

 var tableXtraPostParams = { "process":"fetch", "which":"mine" }; $.each(tableXtraPostParams, function(n, v){ aoData.push( { "name": n, "value": v } ); }); 

Here is what aoData looks aoData before clicking

 [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}] 

And after clicking

 [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"}] 

What i tried to solve

  • I downloaded jQ 1.7.2 (dev edition) and replaced with minified 1.7.2. Without success!
  • I tried to write

.

 for( var p in tableXtraPostParams ) { aoData.push( { "name": p, "value": tableXtraPostParams[p] } ); } 

instead of $ .each. No success!

What am I missing here? I really don't know why this error message appears in the Firefox log when I try to click from inside .. And it still works fine.

Any suggestions would be greatly appreciated!

Note

Here is one version (without $ .each): datatables.net/examples/server_side/custom_vars.html

+4
source share
1 answer

I expect you to make a mistake in this error. If the object and array that you are repeating and complementing are NOT jQuery instances, and you can reproduce it without using $ .each, I think you should see what you do with aoData later.

Sizzle is a selector mechanism, so find a place where you do something like this:

 $(aoData[0]) 

In this hypothetical case, you are doing jQuery, thinking it has a selector, but you passed it something else.

Hope this helps!

+1
source

Source: https://habr.com/ru/post/1412824/


All Articles