【问题标题】:Javascript autocomplete using Jquery - problem使用 Jquery 的 Javascript 自动完成 - 问题
【发布时间】:2010-11-10 16:05:44
【问题描述】:

我正在尝试使用自动完成脚本 http://www.devbridge.com/projects/autocomplete/jquery/.

现在,下载的代码没有回调脚本。我制作了自己的 PHP 脚本 - 没有用。我正在尝试使用 devbridge 的 serviceUrl(绝对),但这也不起作用。网站上的本地版本(月)也在我的网站上运行。但是有回调的就不行了。

以下是我尝试的步骤:

I) 下载http://www.devbridge.com/projects/autocomplete/jquery/ 目录。

二) 1)方法一:我将index.html中的serviceUrl行改为:

serviceUrl: 'http://www.devbridge.com/projects/autocomplete/service/autocomplete.ashx',

不过,只有本地版本的自动完成功能有效。

(serviceUrl 似乎工作正常 - 在浏览器中尝试 http://www.devbridge.com/projects/autocomplete/service/autocomplete.ashx?query=a

2) 方法二:我尝试编写自己的 autocomplete.php,但这也不起作用:

<?php

$temp=$_GET["query"];

 // Return some dummy data that matches the format.
 //json_encode introduces extra quotes ", so I decided to manually format the result

$result="{ query:'$temp',suggestions:['${temp}beria','${temp}byan Arab Jamahiriya','${temp}echtenstein','${temp}thuania'],data:['${temp}lr,'${temp}ly,'${temp}li,'${temp}lt] }";

header('Content-type: application/json');

echo $result;
?>

我检查了每次按键时,都在我的服务器上向 autocomplete.php 发出正确的请求。 (而且“似乎”,php 脚本给出了正确的输出)。但自动完成功能不起作用。

关于如何调试的任何指针?我是否缺少一些文件/模块等?

问候,

日本

【问题讨论】:

    标签: php javascript jquery json autocomplete


    【解决方案1】:

    如果有人觉得这很有用:

    我已经开始使用 code.google.com (http://code.google.com/p/jquery-autocomplete/) 上的解决方案

    重量很轻,使用方便。它有一个小错误(如果删除整个文本,列表不会被删除)。通过添加 8-10 行额外代码来修复它。

    您可以从这里下载文件:

    https://sites.google.com/site/janakporwal/home/javascript-auto-complete

    (直接链接: https://sites.google.com/site/janakporwal/home/javascript-auto-complete/jquery.autocomplete.js?attredirects=0&d=1 )

    【讨论】:

      【解决方案2】:

      页面是否编译?如果不是,我发现这个错误检查脚本很有帮助。

          <?php
      
      
      ini_set('display_errors','1');
      ini_set('display_startup_errors','1');
      error_reporting (E_ALL|E_WARNING|E_PARSE);
      
      include('filename.php');
      ?> 
      

      也许会有所帮助。

      【讨论】:

        猜你喜欢
        • 2010-12-04
        • 2011-08-08
        • 2013-01-22
        • 2016-05-31
        • 2011-10-08
        • 1970-01-01
        • 2011-11-16
        • 2017-06-19
        相关资源
        最近更新 更多