这是我的观点:
def dummy_method(request):
data = simplejson.dumps({'a': 1})
return render_to_response('test.html',data)
我的javascript:
var request = $.ajax({
url: "test",
type: "GET",
dataType: "json",
success: function(data) {
//Popluate combo here by unpacking the json
alert("0"); // This is the first element of the array sent by the server
}
});
我的网址:
url(r'^test$', 'www.views.dummy_method', name='home'),