[web2py] Re: Update javascript object by ajax

2016-09-07 Thread Massimo Di Pierro
I get the problem. That is not valid JSON. You should not generate JSON. response.json(locations) will generate the JSON. def get_locations(): events = db(db.events.id>0).select() locations = map(lambda event: { 'title': event.title, 'link':

[web2py] Re: Update javascript object by ajax

2016-09-06 Thread Gael Princivalle
Javascript error is: Uncaught TypeError: Cannot read property 'lat' of undefined Do I have to add these '[' at the beginning and '']' at the end like in javascript? Anyway with or without the error is the same. Here is the get_locations result: "[{title: 'In collina 26 a salire e 600 a

[web2py] Re: Update javascript object by ajax

2016-09-06 Thread Massimo Di Pierro
definitively you want def get_locations(): return response.json(locations) and $.getJSON instead of $.get. which those changes what errors do you get? On Monday, 5 September 2016 15:51:44 UTC-5, Gael Princivalle wrote: > > Thanks Dave. > > However I'm still having trouble. > > With

[web2py] Re: Update javascript object by ajax

2016-09-05 Thread Gael Princivalle
Thanks Dave. However I'm still having trouble. With that script in the view google maps API load my all locations: I build a Javascript object. var locations = [ {{for event in events:}} {title: '{{=event.title}}', link:

[web2py] Re: Update javascript object by ajax

2016-08-05 Thread Dave S
On Friday, August 5, 2016 at 2:26:51 PM UTC-7, Gael Princivalle wrote: > > Hello. > > I would like to update a javascript array by ajax, keeping the data into > the db. > We talk about markers data for Google maps. > > Here is how I load the data when the page is loaded. > var locations