我创建了一个表单,当我单击提交按钮时,我将 3 值分配给一个 javascript dict 并将其发送到 python 脚本进行处理,但是我的网络浏览器告诉我一个错误!
来自 Json 错误:{u'food': 90, u'cargo': 70, u'fuel': 50} SyntaxError
控制器.js
function customiseCtrl($xhr){
var self = this;
checkPoint();
this.process = function(){
if (checkPoint()){
var newPlayer = {"fuel":value, "food":value2, "cargo":value3 };
$xhr('POST', '/process', newPlayer, function (code, response) {
self.x = response;
});
}
};
}
/process --> python 脚本(我正在尝试读取“info”的信息并将其写入谷歌应用引擎。
def post(self):
user = users.get_current_user()
player = Player();
info = json.loads(self.request.body)
player.fuel = info.fuel
self.response.out.write(info)