逐行阅读json odoo和ajax
我的控制器返回:逐行阅读json odoo和ajax,json,ajax,openerp,odoo-9,odoo-10,Json,Ajax,Openerp,Odoo 9,Odoo 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"}]}) 如何在新的html页面的div加载数据,例如 1奥迪 2宝马 3欧宝 函数callJson(){ 警报
@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"}]})
如何在新的html页面的div加载数据,例如
1奥迪
2宝马
3欧宝
函数callJson(){
警报返回:
{“jsonrpc”:“2.0”,“id”:null,“result”:“{“ids\”:[{“id\”:1,“name\”:“Audi\”,{“id\”:2,“name\”:“BMW\”,{“id\”:3,“name\”:“Opel\”)}阅读此答案并附上注释,您可以使用
JSON.stringify(结果['id'][i]['id'])
阅读此答案和注释,您可以使用
JSON.stringify(结果['id'][i]['id'])
在您的情况下,您不需要使用JSON.dumps
在odoo中,有两种可能的路线类型
@http.route('/my_html_render', type="html", auth="public")
def html_render(self):
value_dict = {'a':'hello'}
return request.render('template_name',value_dict )
@http.route('/my_html_string', type="html", auth="public")
def html_string(self):
return "Hello world"
@http.route('/my_json', type="json", auth="public")
def some_json(self):
return {"ids":[{"id": 1,"name": "Audi"},{"id": 2,"name": "BMW"},{"id": 3,"name": "OPEL"}]}
在您的情况下,不需要使用json.dumps 在odoo中,有两种可能的路线类型
@http.route('/my_html_render', type="html", auth="public")
def html_render(self):
value_dict = {'a':'hello'}
return request.render('template_name',value_dict )
@http.route('/my_html_string', type="html", auth="public")
def html_string(self):
return "Hello world"
@http.route('/my_json', type="json", auth="public")
def some_json(self):
return {"ids":[{"id": 1,"name": "Audi"},{"id": 2,"name": "BMW"},{"id": 3,"name": "OPEL"}]}