所以我在views.py简单的Hello World,AJAX Django的
def home(request):
return render_to_response('proj1/index.html', RequestContext(request, {'variable': 'world'}))
这个功能,我想使用AJAX来显示的 “Hello World”;
Ajax的功能,像这样:
$.ajax({
url: "/proj1"
type:"GET",
dataType: "html",
success: function(data){
<h1>Hello {{data.variable}}, welcome to my AJAX WebSite</h1>
}
});
我如何实现的呢? 谢谢!
如果你想为什么你使用'render_to_response'摆脱Ajax响应,你最好使用'HttpResponse'。 –
我喜欢渲染比http .. :) –
目前还不清楚你在问什么。 –