When I send a JSON string to Django from Ajax, it converts it to an invalid JSON format. In particular, if I look in the posts in Firebug, I send:
info {'mid':1,'sid':27,'name':'aa','desc':'Enter info' }
But when I access it in a django request, I see:
u'{\'mid\':1,\'sid\':27,\'name\':\'aa\',\'desc\':\'Enter Info\'}
When I try to parse this with json.loads, it dies with an invalid JSON message.
I am sending from:
data.info = "{'mid':1,'sid':27,'name':'aa','desc':'Enter info' }";
$.ajax({url: cmdAjaxAddress,
type: "POST",
data: data,
success: function(txt) {
result = txt;
},
async: false });
I read the POST in django as follows:
if request.is_ajax() and request.method == 'POST':
infoJson = request.POST['info']
info = json.loads(infoJson);
Any help would be appreciated.