I'm trying to receive a json object sent from my jquery post call as seen below in the code. I get the "POST OK" callback when the
simplejson.loads(request.POST)
is commented. But as soon i'm trying do do something with the request I get Internal server error 500. Any ideas or any other ways to handle json?
views.py
@csrf_exempt
def post_post(request):
print 'post_post'
if request.method == 'POST':
print 'POST'
messageData = simplejson.load(request.POST)
return HttpResponse(simplejson.dumps("POST OK!"))
else:
return HttpResponse(simplejson.dumps("POST NOT OK!"))
projectViewModel.js
var m = "Hello World";
console.log(m);
$.ajax({
url: 'postNewPost/',
type: 'POST',
dataType: 'json',
data: {client_response: JSON.stringify(m)},
success: function(result) {
console.log(result);
}
});