首页 \ 问答 \ jQuery:Yahoo Autocomplete / Autosuggest(jQuery: Yahoo Autocomplete/Autosuggest)

jQuery:Yahoo Autocomplete / Autosuggest(jQuery: Yahoo Autocomplete/Autosuggest)

我试图检索雅虎自动填充。

雅虎的JSON网址是这样的: http : //ff.search.yahoo.com/gossip?output=fxjson&command=query

所以我有:

   $("selector").autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "http://ff.search.yahoo.com/gossip",
                dataType: "jsonp",
                data: {
                    "output" : "fxjson",
                    "command" : request.term
                },
                success: function( data ) {
                    response(data[1])
                }
            })
        }
    });

这里是一个例子: http : //jsfiddle.net/yQbdb/

有人能发现一个错误,或者我做错了什么? 它应该工作。

谢谢


I'm trying to retrieve yahoo autocomplete.

Yahoo's JSON url is this: http://ff.search.yahoo.com/gossip?output=fxjson&command=query

So I have:

   $("selector").autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "http://ff.search.yahoo.com/gossip",
                dataType: "jsonp",
                data: {
                    "output" : "fxjson",
                    "command" : request.term
                },
                success: function( data ) {
                    response(data[1])
                }
            })
        }
    });

And here is an example: http://jsfiddle.net/yQbdb/

Can someone spot a mistake or what I'm I doing wrong? It should work.

Thanks


原文:https://stackoverflow.com/questions/8380623
更新时间:2024-02-20 10:02

最满意答案

1)谢谢你的“EXPLAIN”。 我们所有人(包括你,我敢肯定) 知道问题是mysql必须将整数转换为字符串,并且必须为每一行执行此操作。 但你的“EXPLAIN”证明了这一点。

2)这是一篇关于EXPLAIN的简短文章:

* possible_keys *显示哪些索引适用于此查询,并且告诉我们实际使用了哪些-...最后, rows条目告诉我们MySQL必须查看多少行才能找到结果集。

Search value:   key:        type:  ref:   rows:  
-------------   ---         ----   ----   ----
5107357058      NULL        ALL    NULL   6482116
'5107357058'    phoneNumber ref    const  2

3)“ref”列是“与索引相比的列”。 在第二种情况下,将字符串文字(“常量”)'5107357058'与键“phoneNumber”进行比较。 在第一种情况下,没有可用的密钥(因为您的搜索条件是完全不同的类型); 因此“ref”为NULL。

4)“类型”列是“连接类型”。 “Ref”表示“从该表中读取具有匹配索引值的所有行”(在本例中为2行)。 “ALL”勒芒“全表扫描”。 在这种情况下,这意味着600万行。

5)这是“EXPLAIN”的mysql文档:


1) Thank you for the "EXPLAIN". We all (including you, I'm sure) knew that the problem was that mysql had to convert the integer to a string, and had to do it for each row. But your "EXPLAIN" proved it.

2) Here's a nice, short article about EXPLAIN:

The *possible_keys* shows which indexes apply to this query and the key tells us which of those was actually used -... Finally the rows entry tell us how many rows MySQL had to look at to find the result set.

Search value:   key:        type:  ref:   rows:  
-------------   ---         ----   ----   ----
5107357058      NULL        ALL    NULL   6482116
'5107357058'    phoneNumber ref    const  2

3) The "ref" column is the "The columns compared to the index". In the second case, the string literal ("constant") '5107357058' was compared to the key "phoneNumber". In the first case, there was no usable key (because your search condition was a completely different type); hence "ref" was NULL.

4) The "type" column is "The join type". "Ref" means "All rows with matching index values are read from this table" (in this case, 2 rows). "ALL" mans "full table scan". Which in this case means 6 million rows.

5) Here's the mysql documentation for "EXPLAIN":

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)