0
假設我有一個Django的views.py功能get_a_color
:如何使用JQuery-getJSON函數從Django視圖中提取JSON數據?
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中獲取數組的第一項? –