Grab array from div text to plot with ChartJS

πŸ‘:0

You say:

Web2Py likes to return the results to an HTML element

But that’s just what the built-in ajax function does.

You can get always data from your controller with jQuery (bundled with web2py):

function getData() {
  $.ajax({
     url: "your_controller/get_data.json?", 
     data: { input1: "hello", input2: "bye"},
     success: function(result){
       //do what you want with result...
     }
  });
}

In the controller:

def get_data():
    response.view = 'generic.json'
    a = request.vars.input1
    b = request.vars.input2
    return {data: [1, 2, 4, 67]}

Leave a comment