var jsData = {
id: 'E1',
firstname: 'Peter',
lastname: 'Funny',
project: { id: 'P1' },
activities: [
{ id: 'A1' },
{ id: 'A2' }
]};
var jsonData = JSON.stringify(jsData);
$('#click').click(function(){
$.ajax({
url: "test/",
type: "POST",
data: jsData,
dataType: "json",
success: function (data){
console.log(data);
},
error:function(){$('#text').html('FATAL_ERROR')}
})
})
This is the JS-Code and jsData should be send to the Server(Python). On the Server i get something like {'{id:'E1',firstname:'Peter',lastname:'Funny',project: { id: 'P1' },activities: [{ id: 'A1' },{ id: 'A2' }]};':''}
Is there a smart way to get the string 'inner dict' out of the 'outer dict' ?!
request.body
and get the data. By the way - when you are usingdataType
is the type you are expecting back from the server. You should usecontentType:"application/json"
to notify the server about the type of the data in your request.