我正在尝试将json对象从javascript发送到pythonwebservice。但服务总是将其视为字符串。以下是客户端和服务器端代码:
客户端:
$("#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",
});
});
服务器端:
^{pr2}$因此,我可以在服务器端看到以下结果:
谁能告诉我这里出什么事了吗?在
我不知道您使用的是哪个模块,但我希望它始终作为字符串传递。如果需要字典,可以使用^{} 来完成:
相关问题 更多 >
编程相关推荐