friends, I'm really freaking out, do not install this application dajax django and now try to do it manually and nothing to make it, the idea is to send from the template, given a variable and return the same variable as a warning, would welcome help me this crazy.
<script type="text/javascript">
var name = 'Joe';
function my_js_callback(){
$.ajax({
type:"POST",
url:"/app/test",
data: {
'name': name
},
success: function(data){
alert(data);
}
});
}
</script>
@login_required
def app_test(request):
if request.is_ajax():
name = request.POST.getlist('name')[0]
message = name
else:
message = "Not Ajax"
return HttpResponse(message)