社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Jquery

如何在输入中写入空间并使用jquery

WebDesign GoldenGuard • 4 年前 • 152 次点击  

我已经搜索了表,但当我这样写空间时:“”它不起作用,我得到了这个错误: 未捕获错误:语法错误,无法识别的表达式:… 输入前的脚本:

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

我的输入是:

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

我的剧本是:

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);
}

以及以下帮助信息: 当有人在输入中写入某些内容,然后按键盘键时,请按如下所示,将表“关键字var”更改为输入值: onKeyUp="table_key=this.value; reload_table();" 然后将一些PHP页面加载到表中,它可以工作并且可以修复,但是当我编写空间时,它不能工作,我不知道我能做什么,我可以做一些像添加引号和双引号但不工作的事情。

我知道一件事,当我写了一些东西并且用任何单词成功地改变了key up table_key var,但是加载脚本不工作,并且在控制台中发送错误时,这个错误是完全错误:

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)

我希望能给你一些好消息,请帮助我

和这个主题相同的bug: JQUERY: Uncaught Error: Syntax error, unrecognized expression 但我在这个话题上找不到帮助我自己的东西

如果有人认为我不使用此库,我会使用此库: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/38116
 
152 次点击  
文章 [ 2 ]  |  最新文章 4 年前
user8840415
Reply   •   1 楼
user8840415    5 年前

我将输入代码更改为:

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

到:

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

在配置页面中,我添加了以下代码:

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

如果有人有更好的想法,请回答

urs_ng
Reply   •   2 楼
urs_ng    5 年前

使用encode uri(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"/>