1、前端。jQuery发送GET请求,并解析json数据。getJSON方法可参考。

url = "http://example/?question=" + question + "&rand=" + Math.random();$.getJSON(url, function(json){    answer = json.answer;    alert(answer);});

2、后端。Django接收GET请求并返回json数据。

from django.http import HttpResponsefrom django.utils import simplejsonif request.method == 'GET' and 'question' in request.GET:    question = request.GET['question']    print(question)    data = {"answer": "answer"}    #ensure_ascii=False用于处理中文    return HttpResponse(simplejson.dumps(data, ensure_ascii=False))

相关阅读:

*** ***