I put together a simple test of an ajax/jquery post within a django framework, but don\'t really understand why the output doesn\'t make it to a template page. Anyone?
I
I can see the contents of the post in firebug's 'response' tab, but whether I try to return a template or a simple message, nothing happens in the browser itself. Conversely, a non-ajax post works as expected (loads new page, posts message)
If you're getting a response, you're getting a response. You're just not doing anything with it.
Why not alert the data and append it to the for example:
$.ajax({
type:"POST",
url:"/test_results/",
data: {
'arbitrary-data': 'this is arbitrary data',
'some-form-field': $("myform input:first").val(), // from form
'background-color': $("body").css("background-color")
// all of this data is submitted via POST to your view.
// in django, request.POST['background-color']
},
success: function(data){
alert(data);
$("body").append(data);
}
});