jaime jaime - 1 year ago 94
Python Question

can i send a message to a django template in an HttpResponseBadRequest?

Can i send an error message attached to an HttpResponseBadRequest which will be displayed in my template?


def myView():
return HttpResponseBadRequest(msg)



This is what happens

Answer Source

You've defined a global JS variable somewhere called msg.

If you want to refer to the data returned by the Ajax error, you need to accept it as a parameter in your fail function:

.fail(function(jqXHR, textStatus, error) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download