如何使用 Python 在 Google App Engine 中实现 jQuery 自动完成?
我找到了几个讨论这个问题的来源,(这个看起来最简单,但它是针对 PHP 的)。我将使用现有的搜索表单,并创建了 AutocompleteResponse 处理程序来处理请求。我从文档中不明白是否需要发送的数据为 json 格式或字符串数组即可。我也不确定要发送什么信息。我创建了一个带有搜索历史记录的新模型
class Search(db.Model):
owner = db.UserProperty()
date= db.DateTimeProperty(auto_now_add=True)
query = db.StringListProperty()
,我想将相关查询建议发送到自动完成。欢迎对示例提供任何帮助,无论是在文档中还是以其他方式。谢谢。
更新
关闭之前
<script>
$('#search_form').autocomplete({
source: "http://ting-1.appspot.com/autocomp",
minLength: 2});
</script>
我把它放在我的Autocomp
处理程序中的
data = json.dumps("abc, def")
我天真地认为data 将传递给 jquery 自动完成插件。但什么也没有发生。我做错了什么?
I found several sources discussing this problem, (this one seems the simplest but it is for PHP). I will be using an existing search form and I created AutocompleteResponse
handler to handle the request. I don't understand from the documentation if it is required that the data sent will be in json format or an array of string is ok. I am not sure about what information to send either. I created a new model with search history
class Search(db.Model):
owner = db.UserProperty()
date= db.DateTimeProperty(auto_now_add=True)
query = db.StringListProperty()
and I want to send the relevant query suggestions to autocomplete. Any help to examples whether in documentation or otherwise is welcome. Thanks.
Update
I put this just before the closing </body>
<script>
$('#search_form').autocomplete({
source: "http://ting-1.appspot.com/autocomp",
minLength: 2});
</script>
in my Autocomp
handler I put
data = json.dumps("abc, def")
I naively think that data
will be passed to jquery autocomplete plug in. But nothing is happenning. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚尝试过这个并且它有效:
Just tried this and it worked: