[英]How do I send/get a JSON Object with Django?
I know how to use the JQuery ajax feature to call the "url view" of Django. 我知道如何使用JQuery ajax功能来调用Django的“ URL视图”。
import simplejson as json
def the_view(request):
fruits = {'color':5, 'type': 22}
jfruit = json.dump(fruits)
return render_to_response( THE JSON OBJECT!!! ...how? )
Or shorter: download http://bitbucket.org/offline/django-annoying/ and write: 或更短:下载http://bitbucket.org/offline/django-annoying/并编写:
@ajax_request
def the_view(request):
return {'color':5, 'type': 22}
There are a few such nice tiny things in django-annoying. django-annoying中有一些非常好的小事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.