Ah, thanks Anthony. I didn't realize that the third argument in the ajax()
function was that flexible. That helps.

Ian

On Wed, Jan 20, 2016 at 4:45 PM, Anthony <abasta...@gmail.com> wrote:

> Additionally, if you still want to use the ajax() function, the third
> argument can be ":eval", in which case, you can return some Javascript code
> to be executed when the response is returned. Alternatively, the third
> argument can be an actual Javascript function, in which case, the returned
> value will be passed to that function.
>
> Anthony
>
>
> On Wednesday, January 20, 2016 at 4:20:22 PM UTC-5, Ian W. Scott 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/4gSYo-Th4vw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Ian W. Scott, PhD (McMaster RS)
Associate Professor of New Testament
Tyndale Seminary
Toronto, Ontario, Canada
http://www.ian-w-scott.com

*Paul's Way of Knowing: Story, Experience and the Spirit* (WUNT II/205;
Tübingen: Mohr Siebeck, 2006/Grand Rapids: Baker Academic, 2008).

*The Online Critical Pseudepigrapha* (Atlanta: Society of Biblical
Literature, 2006-). Online: http://www.purl.org/net/ocp.

-- 
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.

Reply via email to