When I post a JSON string to Django by Ajax, it converts it into an invalid JSON format. Specifically, if I look in the post data in Firebug I am sending:
info {'mid':1,'sid':27,'name':'aa','desc':'Enter info' }
Yet when I access it in the django request I am seeing:
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 posting with:
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 am reading the POST in django like this:
if request.is_ajax() and request.method == 'POST':
infoJson = request.POST['info']
info = json.loads(infoJson);
Any help would be appreciated.