Skip to Content
मेन्यू
This question has been flagged
2 Replies
4895 Views

odoo.define('module.custom_name', [] ,function (require) {

"use strict";
const rpc = require('web.rpc');
var ajax = require('web.ajax');

$(document).ready(function () {

$('#custom_btn').on('click', function (event) {

ajax.jsonRpc("/controller", 'call', {
 --------
}).then(function(data) {
 -------------
});
this structure is not working. How to do controller call in odoo 17?

Avatar
Discard
Best Answer

Hi,First import jsonrpc from rpc_service: and try following,to add custom logic inside the then function,
/** @odoo-module **/

import { jsonrpc } from "@web/core/network/rpc_service";

$(document).ready(function () {

$('#custom_btn').on('click', function (event) {await jsonrpc('/controller', {}).then( function(data){
         ---------
            })
    }

If we have any context data, const token = await jsonrpc('/totphook', {
            secret: $secret.text()
        });

Hope it helps,

Avatar
Discard
Author

Thanks a lot. It worked.

Best Answer

Hi junaid,

and check 


Thanks.

Avatar
Discard
Author

Thanks a lot. It worked.
In the other solution "jsonrpc" seems to give much faster response. But Thanks again. Badly needed a solution.

yes junaid

Related Posts Replies Views Activity
0
फ़र॰ 19
4233
1
अग॰ 24
2131
1
नव॰ 21
6362
2
जन॰ 17
29168
1
फ़र॰ 16
4018