I'm trying to use .get() in jQuery to send a request to server and return a python object using Django framework. By using
data = serializers.serialize('json', ExampleModel.objects.all())
return HttpResponse(data, 'application/json')
I can get a collection of objects at javascript end like this: [object Object][object Object] But it seems impossible to call any parameters or functions from those objects. I've tried this:
for (x in data){
alert(data[x].parameter);
}
I just get several "undefined" as a result. Can anybody explain why? Thanks.
console.log(data)
andconsole.log(x)
and show some results here so we can see the structure of the objects. – Simeon Visser Mar 30 '12 at 21:49console.dir
might give you something more useful. – Karl Knechtel Mar 31 '12 at 1:33