所以我在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 .. :) –
目前還不清楚你在問什麼。 –