javascriptjsonmodel-view-controllerodoobryntum-scheduler

How to recive JSON data from odoo controller to a specific js file (ExtJS)


I want to add a bryntum schedule (ExtJS framework) to my odoo module but I have problem with transferring data from and to its js file

my controller :

@http.route('/testjs', type="json", auth='public', website=True)
    def test(self):    
    return [{'name': 'amor', 'age': '20'},           
           {'name': 'james', 'age': '21'}]

and the js file is part which receives data:

 var resourceStore = new Sch.data.ResourceStore({   
         model   : 'Sch.model.Resource'});
 
 resourceStore.loadData([  //static data for test  
     {        Id      : 'a',        Name    : 'Rob'    },    
     {        Id      : 'b',        Name    : 'Mike'    }]);

note: I think I should use a proxy, but I don't know how


Solution

  • you can try something like

    $.getJSON('/testjs?',
        function(data) { ... }
    );
    

    for more info http://api.jquery.com/jQuery.getJSON/