SO中文参考
首页
(current)
程序语言
c
java
python
c++
go
javascript
swift
c#
操作系统
linux
ubuntu
centos
unix
数据库
oracle
mysql
mongodb
postgresql
框架
node.js
angular
react-native
avalon
django
twisted
hadoop
.net
移动开发
android
ios
搜索
如何实现 CloudSearch Amazon 和 Jquery 自动完成功能?</desc> <question vote="0"> <p>我在使用 Jquery 插件自动完成功能检索数据时遇到了问题。这是我的例子:</p> <pre><code><!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Autocomplete - Remote JSONP datasource</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <!-- <link rel="stylesheet" href="/resources/demos/style.css"> --> <style> .ui-autocomplete-loading { background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat; } #city { width: 25em; } </style> <script> $(function() { function log( message ) { $( "<div>" ).text( message ).prependTo( "#log" ); $( "#log" ).scrollTop( 0 ); } $( "#city" ).autocomplete({ source: function( request, response ) { //$.getJSON('/http://search-profuturo-iiwjjl6diqb7gluv2inqunahea.us-west-2.cloudsearch.amazonaws.com/2013-01-01/search?', { q: request.term }, function(data){ response(data); }); $.ajax({ url: "http://search-DOMAIN-iiwjjl6diqb7gluv2inqunahea.us-west-2.cloudsearch.amazonaws.com/2013-01-01/search?", dataType: "jsonp", data: { q: request.term }, success: function( data ) { response( data ); } }); }, minLength: 3, select: function( event, ui ) { log( ui.item ? "Selected: " + ui.item.label : "Nothing selected, input was " + this.value); }, open: function() { $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); }, close: function() { $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); } }); }); </script> </head> <body> <div class="ui-widget"> <label for="city">Your city: </label> <input id="city"> </div> <div class="ui-widget" style="margin-top:2em; font-family:Arial"> Result: <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div> </div> </body> </html> </code></pre> <p>这是回应:</p> <pre><code>http://search-DOMAIN-iiwjjl6diqb7gluv2inqunahea.us-west-2.cloudsearch.amazonaws.com/2013-01-01/search?&callback=jQuery11020041068303398787975_1421364823901&q=starwars&_=1421364823902 </code></pre> <p>这将附加所有字符串:</p> <pre><code>&callback=jQuery11020041068303398787975_1421364823901 </code></pre> <p>那是错误,那个字符串不是必需的。</p> <p>我需要这样的网址:</p> <pre><code>http://search-DOMAIN-iiwjjl6diqb7gluv2inqunahea.us-west-2.cloudsearch.amazonaws.com/2013-01-01/search?q=starwars </code></pre> <p>我需要一个 JSON 响应。</p> <p>我该怎么办?</p> </question> <answer tick="false" vote="0"> <p><strong>试试这个</strong></p> <pre><code>$.ajax({ url: 'http://search-DOMAIN-iiwjjl6diqb7gluv2inqunahea.us-west-2.cloudsearch.amazonaws.com/2013-01-01/search', data: { q: 'starwars' } jsonp : false, jsonpCallback: 'jsonCallback', cache: 'true', dataType: 'jsonp' }); function jsonCallback(data) { console.log(data); } </code></pre> </answer> </body></html>
问题描述
投票:0
回答:0
javascript
jquery
amazon-cloudsearch
最新问题
pkzip APPNOTE 中的“幻数”(0xdebb20e3) 是什么?
Chrome Headless puppeteer 占用太多 CPU
如何在powershell中检测剪贴板图像的变化
DynamoDB 一致性
当我使用 SMS 用户同意 API 时,FirebasePhoneAuth 崩溃
包含文本的 CSS 三角形
尝试创建新文档时出现 Mongoose 错误
如何使用ggplot重绘LASSO回归图?
如何将具有多个参数的函数作为回调/函数指针传递?
如何拥有多个版本的网站(具有不同类型的内容)?
pyinstaller 之后的 Python 复制
启动 PyQt 应用程序而不阻塞主线程
如何在Java中访问GPIO引脚?
有什么方法可以处理 Rust 中嵌套的 ok_or() 吗?
使用 Swup - 在每个文件上重新加载 javascript
自定义构建类型依赖处理程序问题
SQL - 帮助:如何在表中查找独立工作的作者?
另一个网站上的 Php 反向链接检查器
Databricks - 不为空,但它不是 Delta 表
当我有超过 1700 个活动或存档版本时,如何删除 Google Apps 脚本中的旧部署(版本)?
© www.soinside.com 2019 - 2024. All rights reserved.