Vineet
unread,Feb 21, 2012, 4:36:59 AM2/21/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
Earlier i was using ajax() function.
But since it is not possible to send js array or json object, I am
trying $.ajax function.
--- View ---
var jsonObjects = [{id:1, name:"amit"}, {id:2, name:"ankit"},{id:3,
name:"atin"},{id:1, name:"puneet"}];
$.ajax({
url: "{{=URL('myControllerName')}}",
type: "POST",
context: document.body,
data: {students: JSON.stringify(jsonObjects) },
dataType: "json",
success: function(){
alert('ok');
}
});
--- end View ---
In controller, how do I access the data?
Somebody has give the code for grails as :---
//this code is written in grails
import grails.converters.JSON;
List<JSON> students = JSON.parse(params.students) //students in
request params is parsed to json objects and stored in the List
println "Student id: " + students[0].studentId //first element of
the students list is accessed as a map holding a key studentId
In web2py, how to port this code?
Thanks,
Vineet