跳至内容
菜单
此问题已终结
1 回复
11237 查看

I try to get data from odoo server using js, but I have a problem when I print this data I get undefined how I can solve this problem I want to get this data outside .then

        var ajax = require('web.ajax');
        var result;
        ajax.jsonRpc("/get_data", 'call', {}, {
            'async': false
        }).then(function (data) {
            result = data;
        });
        console.log(result); // undefined

形象
丢弃
最佳答案

Hi,

Can you try the code like below

var ajax = require('web.ajax');
var result = [];
ajax.jsonRpc("/get_data", 'call', {}, {
'async': false
}).then(function (data) {
result.push(data);
});
console.log(result)

Regards

形象
丢弃

For me it's works!

i have added return result ; statement at last it is returning empty array..how can return that value?

相关帖文 回复 查看 活动
1
7月 20
6508
0
7月 25
290
1
7月 25
5068
0
7月 25
628
0
6月 25
698