Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6795 มุมมอง

Hello, can you give me an example for getting a value from python to javascript?

I always get across browser origin error.

I tried to get a value from this:


.py

@http.route('/custom/test', type='json', auth="public", methods=['POST'], website=True)

    def person(self, lastname, firstname):

   

        headers = {'Content-Type': 'application/json'}

        create_user_url = "http://localhost:8090/custom_custom/user"

        data = {"jsonrpc": 2.0, "params": {"lastname": lastname, "firstname": firstname} } 

       

.js

if (result) {										    session.rpc('/custom/test', {											        lastname : // how to get the data from python?											        firstname: // how to get the data from python?											    }).then(function (result) {												        console.log("print user")
     });
}
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
Hi Kinah Guinto,

Try this way

Js:

this._rpc({

model: 'model.name',

method: 'get_person',

args: [],

}).done(function(data){

   // response block

});

Python:

@api.model

def get_person(self):

    # code stuff


It can be done by using RPC calls.

อวตาร
ละทิ้ง
ผู้เขียน

Hi Padhmanaban,

I am trying to get the function from controller.

Can you give me some examples for that?

I appreciate your response.

Thank you

ผู้เขียน

Hi Padhmanaban,

Thank you for your response.

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ธ.ค. 22
5762
0
ธ.ค. 24
934
0
พ.ย. 24
1148
0
ม.ค. 24
6893
0
มี.ค. 21
1925