I am trying to send a json object from javascript to a python webservice. But the service always treats it as a string. Below are the client and server side codes:
CLIENT SIDE:
$("#button").click(function () {
$.ajax({
type: "POST",
url: "http://localhost:8079/add",
data: JSON.stringify([{'account_template': {
'external_id': 'l10n_harec.a' + $("input[id$=Text2]").val(),
'name': $("input[id$=Text1]").val(),
'code': $("input[id$=Text2]").val(),
'type': $("select[id$=accountType]").val(),
'reconcile': $("input[id$=Checkbox1]").val()
}, 'account_account': {
'code': $("input[id$=Text2]").val(),
'name': $("input[id$=Text1]").val(),
'type': $("select[id$=accountType]").val(),
'active': 'True',
'reconcile': $("input[id$=Checkbox1]").val()
}
}]),
dataType: "json",
});
});
SERVER SIDE:
class add:
def POST(self):
i = web.input()
print i
I can see the following on server side as a result:
Can anyone tel what is wrong here?