0

I have made search for table and this working good but when i write space like this : ' ' it's don't working and i got this error : Uncaught Error: Syntax error, unrecognized expression: ... My script before my input :

var table_length=10,table_key="",page=1;

My input is :

<input onKeyUp="
    table_key=this.value;
    reload_table();" type="search" class="form-control input-sm" placeholder="" aria-controls="datatable-responsive">

My script is :

function reload_table(){
    $("#load_table").load("manage_table_engine.php?mode=tr&table=generator_tables&table_id=1&length=" + table_length + "&key=" + table_key + "&page=" + page);
}

And this information for help : When someone writing something in input and then keyup the keyboard do change the table_key var to input value as you see in input like this : onKeyUp="table_key=this.value; reload_table();" And then load some php page to the table and it's working and fixed but when i writing space it's not working and i don't know what can i do , i do something like add quotes and double quotes but not working.

And i know one thing when i writing something and key up table_key var changed successfully with any word but load script is not working and sending error in console this error is full error :

Uncaught Error: Syntax error, unrecognized expression: &page=1
at Function.oe.error (jquery.min.js:2)
at oe.tokenize (jquery.min.js:2)
at Function.oe [as find] (jquery.min.js:2)
at w.fn.init.find (jquery.min.js:2)
at Object.<anonymous> (jquery.min.js:2)
at u (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at k (jquery.min.js:2)
at XMLHttpRequest.<anonymous> (jquery.min.js:2)

I hope give you good information pls help me

and it's bug same this topic : JQUERY: Uncaught Error: Syntax error, unrecognized expression but i don't found some thing in this topic for help my self

I use this if someone think i don't use this library :<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

2 Answers2

0

Encode the load method input using encodeURI(uri);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
    var table_length=10,table_key="",page=1;
    function reload_table(){
        $("#load_table").load(encodeURI("manage_table_engine.php?mode=tr&table=generator_tables&table_id=1&length=" + table_length + "&key=" + table_key + "&page=" + page));
    }
</script>
<input onKeyUp="table_key=this.value;reload_table();" type="search" class="form-control input-sm" placeholder="" aria-controls="datatable-responsive"/>
urs_ng
  • 33
  • 11
  • dude i write it's working you didn't see that? how this working with out jquery.min.js library do you think???? i have this. it's not working when i write space! –  Sep 24 '18 at 22:21
  • Can you post the #loadtable code, you mean to say its not getting reloaded ? – urs_ng Sep 24 '18 at 22:25
  • its not getting reload when i write space i mean when i write a or b or c or abc or something it's working but when i write a b or c a or b a or something has space it's not working –  Sep 24 '18 at 22:30
0

I change my input code from :

<input onKeyUp="
table_key=this.value;
reload_table();" type="search" class="form-control input-sm" placeholder="" aria-controls="datatable-responsive">

To :

<input onKeyUp="
table_key=this.value.replace(' ', '***space***');
reload_table();" type="search" class="form-control input-sm" placeholder="" aria-controls="datatable-responsive">

And in config page i add this code :

/*php*/ $key=str_replace("***space***"," ",$_GET['key']);

And this working if someone has better idea post answer pls