【发布时间】:2017-05-08 11:36:10
【问题描述】:
我的控制器返回:
@http.route('/my_json', type="json", auth="public")
def some_json(self):
return json.dumps({"ids":[{"id": 1,"name": "Audi"},{"id": 2,"name": "BMW"},{"id": 3,"name": "OPEL"}]})
如何在 div 中的新 html 页面中加载数据,例如。
1 奥迪
2 宝马
3 欧宝
函数调用Json() {
$.ajax({
type: "POST",
url: "/test_json",
async: false,
data: JSON.stringify({}),
contentType: "application/json",
complete: function (data) {
alert(data["responseText"])
},
error: function () {
alert("Error")
}
});
警报返回:
{"jsonrpc": "2.0", "id": null, "result": "{\"ids\": [{\"id\": 1, \"name\": \"Audi\ "}, {\"id\": 2, \"name\": \"BMW\"}, {\"id\": 3, \"name\": \"Opel\"}]}"}
【问题讨论】:
标签: json ajax openerp odoo-9 odoo-10