Reputation: 721
Can anyone help me out of this problem, my javascript has an ajax GET Http request:
$.ajax({
url:"/testPage",
type:'GET',
success: function(){
alert("done");
}
});
the server end python app has a handler to handle the Http request from js:
class testPageHandler(webapp.RequestHandler):
def get(self):
path=os.path.join(os.path.dirname(_file_).'page1.html')
template_values={}
self.response.out.write(template.render(path,template_values))
def post(self):
.....
application=webapp.WSGIApplication([('/testPage',testPageHandler),
.....
In "get" method, I would like the Django template "page1.html" gets rendered, so the browser displays "page1.html" page, rather than just pops up "done". any idea? thanks in advance.
Upvotes: 2
Views: 1712
Reputation: 1803
Django template is actually rendered and returned as response body. Now you just want to process it on client side.
$.ajax({
url:"/testPage",
type:'GET',
success: function(html){
$('body').append(html);
}
});
You can manipulate the response in whatever way you like. In the example above it is just appended to the body
tag.
Upvotes: 3