JavaScript XML-RPC调用未执行 [英] JavaScript XML-RPC call not executing
本文介绍了JavaScript XML-RPC调用未执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用html文件中的javascript调用python方法.以下是我的html文件:
I am trying to call a python method using javascript from my html file. Below is my html file:
<html>
<head>
<title>Gadget</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="xmlrpc.js"></script>
</head>
<body>
<button onclick="call()">Select</button>
<script>
function call() {
$.xmlrpc({
url: 'my_odoo_server',
methodName: 'web_login',
params: ['admin', 'i-011d151e9af5b5588'],
success: function(response, status, jqXHR) {
console.log(response)
},
error: function(jqXHR, status, error) {}
});
}
</script>
</body>
</html>
但是xml-rpc调用未完全执行.请帮助解决此问题.
But the xml-rpc call is not executed completely. Please help to solve this problem.
这是控制台映像.
推荐答案
首先,您应该在base.xml文件中扩展视图,例如:
first of all, you should extend the view in your base.xml file for example :
<t t-extend="ListView.buttons">
t t-jquery=".oe_list_buttons" t-operation="append">
<button type="button" oe_button oe-c1>My button</button>
</t>
然后您从js调用函数:
then you call your function from js:
var $c_1_button = this.$buttons.find(".oe-c1");
$c_1_button .click(function() {
var mod=new instance.web.Model("your.model");
mod.call("your_python_function",[params],{}).done(function(res) { });
这篇关于JavaScript XML-RPC调用未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文