<tfoot id='5QSIR'></tfoot>
<i id='5QSIR'><tr id='5QSIR'><dt id='5QSIR'><q id='5QSIR'><span id='5QSIR'><b id='5QSIR'><form id='5QSIR'><ins id='5QSIR'></ins><ul id='5QSIR'></ul><sub id='5QSIR'></sub></form><legend id='5QSIR'></legend><bdo id='5QSIR'><pre id='5QSIR'><center id='5QSIR'></center></pre></bdo></b><th id='5QSIR'></th></span></q></dt></tr></i><div id='5QSIR'><tfoot id='5QSIR'></tfoot><dl id='5QSIR'><fieldset id='5QSIR'></fieldset></dl></div>

<small id='5QSIR'></small><noframes id='5QSIR'>

  1. <legend id='5QSIR'><style id='5QSIR'><dir id='5QSIR'><q id='5QSIR'></q></dir></style></legend>

      • <bdo id='5QSIR'></bdo><ul id='5QSIR'></ul>
    1. jQuery 自动完成 Mysql PHP

      jQuery Autocomplete Mysql PHP(jQuery 自动完成 Mysql PHP)

        <tfoot id='BLl6Z'></tfoot>

          <small id='BLl6Z'></small><noframes id='BLl6Z'>

              <tbody id='BLl6Z'></tbody>
              <bdo id='BLl6Z'></bdo><ul id='BLl6Z'></ul>

            • <i id='BLl6Z'><tr id='BLl6Z'><dt id='BLl6Z'><q id='BLl6Z'><span id='BLl6Z'><b id='BLl6Z'><form id='BLl6Z'><ins id='BLl6Z'></ins><ul id='BLl6Z'></ul><sub id='BLl6Z'></sub></form><legend id='BLl6Z'></legend><bdo id='BLl6Z'><pre id='BLl6Z'><center id='BLl6Z'></center></pre></bdo></b><th id='BLl6Z'></th></span></q></dt></tr></i><div id='BLl6Z'><tfoot id='BLl6Z'></tfoot><dl id='BLl6Z'><fieldset id='BLl6Z'></fieldset></dl></div>
              <legend id='BLl6Z'><style id='BLl6Z'><dir id='BLl6Z'><q id='BLl6Z'></q></dir></style></legend>
              • 本文介绍了jQuery 自动完成 Mysql PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                有人可以看看这个,让我知道我哪里出错了.我正在尝试让 jQuery UI 自动完成工作.这是我的代码:这是search.php

                include "db_connect.php";$search = $_GET['term'];$result = mysql_query("SELECT Title FROM `movie` WHERE `Title` LIKE '%$search%' ORDER BY Title ASC") or die('出了问题');$rows = array();而 ($row = mysql_fetch_assoc($result)){$rows[] = $row;}打印 json_encode($rows);?>

                这是我的 javascript 内联脚本

                这是自动"div

                <p><input type="text" id="auto"/></p>

                当我使用 firebug 查看调用时,我看到 search.php 正在返回

                [{"Title":"罪恶之城"}]

                jQuery 只是显示 UNDEFINED有什么想法吗??

                解决方案

                查看 jquery ui 自动完成文档.您返回的 JSON 与自动完成功能正在寻找的内容不匹配.您返回的对象必须具有名为 label 或 value(或两者)的属性.

                您可以尝试以下选项:

                选项 1:更改返回的 JSON

                更改返回的 JSON 以包含标签/值属性,例如:

                [{标签":罪恶之城"}]

                从示例中它似乎也使用了 id 属性.我相信以上是自动完成显示值列表的最低要求.我认为你也可以返回一个字符串数组,它会以与上面完全相同的方式呈现它.

                [ 《罪恶之城》、《等等》]

                选项 2:更改私有 _render 函数

                更改自动完成的私有 _renderItem 函数以使用您的自定义属性,如此 自动完成示例所示(未经测试):

                $( "#project" ).autocomplete({来源:./search.php",最小长度:3}).data(自动完成")._renderItem = function( ul, item ) {返回 $( "
              • ").data( "item.autocomplete", item ).append( item.Title ).appendTo(ul);};

                这有点灵活,但恕我直言更丑陋.

                Hi could some one please take a look at this and let me know where I'm going wrong. I am trying to get jQuery UI autocomplete to work. this is my code: This is search.php

                include "db_connect.php";
                $search = $_GET['term'];    
                    $result = mysql_query("SELECT Title FROM `movie` WHERE `Title` LIKE '%$search%' ORDER BY Title ASC") or die('Something went wrong');
                    $rows = array();
                    while ($row = mysql_fetch_assoc($result)){
                        $rows[] = $row;
                
                    }
                print json_encode($rows);
                ?>
                

                this is my javascript inline script

                <script type="text/javascript">
                    $(document).ready(function()
                    {
                        $('#auto').autocomplete(
                        {
                            source: "./search.php",
                            minLength: 3
                        });
                    });
                </script>
                

                and this is the 'auto' div

                <div id="searchTxtFieldDiv">
                <p><input type="text" id="auto" /></p>
                </div>
                

                When I look at the call using firebug I see that search.php is returning

                [{"Title":"Sin City"}]
                

                jQuery is just displaying UNDEFINED any ideas??

                解决方案

                Have a look at jquery ui autocomplete documentation. The JSON you are returning does not match what the autocomplete is looking for. The object you return must have properties named label or value (or both).

                You can try the following options:

                Option 1: Change returned JSON

                Change the JSON being returned to include the label/value properties such as:

                [{"label":"Sin City"}]
                

                From the examples it also seems to use the id property. I believe the above is the minimum requirement for the autocomplete to display a list of values. I think you can also return an array of strings and it will render it in exactly the same way as the above.

                [ "Sin City", "Etc" ]
                    
                

                Option 2 : Change private _render function

                Change the private _renderItem function for the autocomplete to use your custom properties as shown in this autocomplete example (untested):

                $( "#project" ).autocomplete({
                    source: "./search.php",
                    minLength: 3    
                })
                .data( "autocomplete" )._renderItem = function( ul, item ) {
                    return $( "<li></li>" )
                   .data( "item.autocomplete", item )
                   .append( item.Title )
                   .appendTo( ul );
                };
                

                This is a bit more flexible but much uglier imho.

                这篇关于jQuery 自动完成 Mysql PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                <i id='ILr2c'><tr id='ILr2c'><dt id='ILr2c'><q id='ILr2c'><span id='ILr2c'><b id='ILr2c'><form id='ILr2c'><ins id='ILr2c'></ins><ul id='ILr2c'></ul><sub id='ILr2c'></sub></form><legend id='ILr2c'></legend><bdo id='ILr2c'><pre id='ILr2c'><center id='ILr2c'></center></pre></bdo></b><th id='ILr2c'></th></span></q></dt></tr></i><div id='ILr2c'><tfoot id='ILr2c'></tfoot><dl id='ILr2c'><fieldset id='ILr2c'></fieldset></dl></div>
                <tfoot id='ILr2c'></tfoot>
                  <tbody id='ILr2c'></tbody>

                        • <bdo id='ILr2c'></bdo><ul id='ILr2c'></ul>

                        • <small id='ILr2c'></small><noframes id='ILr2c'>

                          <legend id='ILr2c'><style id='ILr2c'><dir id='ILr2c'><q id='ILr2c'></q></dir></style></legend>