I would like to send a simple HTTPResponse from Django. My code ist the following:
jsonMessage = {
"message": "Works",
}
return HttpResponse(simplejson.dumps(jsonMessage), mimetype='application/json')
At the client I just get HTML Code and do not know how to handle it. I guess that the client is the problem. My code:
$.ajax({
'url': path,
'type': method,
'data': data,
'cache': false,
'processData': false,
'contentType': false,
'headers': {
'X-CSRFToken': $.cookie('csrftoken')
},
'success': function(data) {
},
}).done(function(response,status, jqXHR ) {
alert(response);
});
The server side works well. But the response is HTML Code not the text I would like to get. I tried also response.message. But this is undefined. I think that I should parse the JSON Code. But I am not sure where it is delivered.Hope you can help me,