jQuery自动完成不返回结果与é [英] jquery autocomplete not returning results with é
问题描述
我很难用JQquery自动完成脚本。
例如:搜索查询test成功返回类似test的结果, ,testéetc
,但是当我将é添加到搜索查询中时,它不再给出任何结果:(查询testé不返回任何结果)。
当我调用执行查询并返回结果作为json数组的php脚本,它显示我正确的输出: [{id:1230,value :Test \\\é}] ,它只是在HTML页面上的下拉菜单中没有给出结果。
我完全发现它。像往常一样,它很简单:
在javascript部分中,我用JSON替换了q: escape .term)byq: encodeURI (request.term)。这解决了我的问题!
$(#field)
.autocomplete({
source:function ){
$ .getJSON(./ ajax / json_search.php,{
object_type:artists,
q:encodeURI(request.term)
},response) ;
}
})
I'm having a hard time with a JQquery Autocomplete script. It works fine until I perform a search with a non-UTF8-character in the search query.
For instance: search query "test" succesfully returns results like "test", "test é" etc but when I add the é to the search query it doesn't give any results any more: (query "test é" returns no results).
When I call the php script that performs the query and returns the the results as an json-array it does show me the correct output: "[{"id":"1230","value":"Test \u00e9"}]", it just on the HTML-page that te drop-down with the results is not given anymore.
any advice on this is hugely appreciated.
Walter
I -finally- found it. And, as usual, it's pretty simple:
In the javascript part where I cal the JSON-script I replaced "q: escape(request.term)" by "q: encodeURI(request.term)". That solved my issue!
$("#field")
.autocomplete({
source: function( request, response ) {
$.getJSON("./ajax/json_search.php", {
object_type: "artists",
q: encodeURI(request.term)
}, response);
}
})
这篇关于jQuery自动完成不返回结果与é的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!