我应该如何响应jquery自动完成请求? [英] What should I respond to jquery autocomplete request?

查看:63
本文介绍了我应该如何响应jquery自动完成请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.
我想通过瓶子网络框架制作一个简单的python网络脚本,该脚本将使用jQuery UI,如下所示:具有远程数据源的jQuery UI自动完成.

这是服务器端代码(尝试1):

 @ get('/search.php')
def autocomplete():
#按request.GET ['term']搜索,然后:
返回['aaa','bbb'] 


我看到响应代码200,但什么都没发生.

这是服务器端代码(尝试2-JSON):

 @ get('/search.php')
def autocomplete():
#按request.GET ['term']搜索,然后:
返回 [
{'id':'001','label':'green birg','value':'green bird'},
{'id':'002','label':'blue birg','value':'blue bird'}
] 


我看到了响应代码500-也不起作用.

所以我应该对jQuery自动完成请求做出什么反应?

解决方案

AAaaarggh愚蠢的瓶子:(它没有制作json ...手工制作的json可以正常工作. /blockquote>

Hello.
I want to make a simple python web-script via bottle web-framework that will use jQuery UI like here: jQuery UI autocomplete with remote datasource .

This is the server-side code (attempt 1):

@get('/search.php')
def autocomplete():
	#search by request.GET['term'], then:
	return ['aaa', 'bbb']


I saw response code 200 and nothing happened.

This is the server-side code (attempt 2 - JSON):

@get('/search.php')
def autocomplete():
	#search by request.GET['term'], then:
	return [
	{'id':'001', 'label':'green birg', 'value':'green bird'},
	{'id':'002', 'label':'blue birg',  'value':'blue bird'}
		]


I saw response code 500 - it didn''t work too.

So what should I respond to jquery autocomplete request?

解决方案

AAaaarggh stupid bottle :( It didn''t make json... Hand-made json works fine.


这篇关于我应该如何响应jquery自动完成请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆