【发布时间】:2011-09-17 21:51:18
【问题描述】:
假设我在 Django views.py 中有函数 get_a_color:
from django.utils import simplejson
def get_a_color(request):
colors = ['red', 'blue', 'yellow']
data = simplejson.dumps(colors)
return HttpResponse(data, mimetype='application/javascript')
我将如何提取颜色“红色”,例如使用 jQuery $.getJSON 函数?
【问题讨论】:
-
你到底在问什么?如何在Javascript中获取数组的第一项?
标签: jquery django django-templates django-views