Yes always better to parse it... On Wed, Jan 20, 2016 at 4:20 PM, Ian W. Scott <scotti...@gmail.com> wrote:
> Thanks. So to clarify, if I serialize the return value as json in the > controller, then I can use it in javascript. It looks like I still have to > parse the json on the javascript end (like $.parseJSON(mydata)) but it > works like a charm. > > Ian > > > On Wednesday, January 20, 2016 at 2:50:35 PM UTC-5, Niphlod wrote: >> >> from gluon.serializers import json >> >> def uh(): >> return json(blablabla) >> >> On Wednesday, January 20, 2016 at 8:45:55 PM UTC+1, Ian W. Scott wrote: >>> >>> I'm trying to use ajax calls to update the data for a chart dynamically. >>> I don't want to make the chart a component that refreshes, I just want to >>> get the controller return value back to the javascript in the view, so that >>> I can update the chart via javascript. But web2py's ajax function seems to >>> only (a) update a part of the page html, or (b) send page data to the >>> controller for use in the back-end. There doesn't seem to be any way to get >>> the controller's return value as a data object for the javascript to use. >>> >>> I've tried just using jquery's get() method like this: >>> >>> $.get(my_controller_url, function(data){ >>> console.log('got ajax data', data); >>> }); >>> >>> But if the controller's return value is a tuple there seems to be no >>> data sent back, or at least I don't know how to access it from the 'data' >>> variable in this example. If I make the controller a dictionary I get html >>> back. But I don't want html. I just want the data. >>> >>> So how can I do this? >>> >> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.