Yea, that was it. I guess I wasn't quite clear on what was getting
passed back from the ajax call. I didn't realize obj.PythonList was
already a javascript array.

Thanks for your response, sorry my code wasn't very clear.

On Feb 13, 3:10 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> Unfortunately your question is not clear, and this "clarification"
> does not really help matters. As far as I can tell, obj.PythonList is
> already an array. If you do:
>    jArray = [obj.PythonList]
> then yes, jArray[0] is indeed the whole contents of obj.PythonList.
> But I don't understand why you want to do this - why not just
> obj.PythonList[0] which should be 3?
> --
> DR.
>
> On Feb 13, 7:04 pm, robinne <develo...@computer-shoppe.net> wrote:
>
> > I put in wrong variable name:
>
> > > var PIDS = obj.PackageIDS; //this brings back 3,2 for example, an
> > > array of integers.
>
> > should be...
>
> > var PIDS = obj.PythonList;
>
> > On Feb 13, 10:10 am, robinne <develo...@computer-shoppe.net> wrote:
>
> > > I am trying to pass an array of integers from a view to javascript in
> > > an ajax call.
>
> > > I know how to return json dump from a View so that javascript can
> > > access it as an object like this:
>
> > > VIEW
> > > response_dict = {"PythonList": MyList, "EditType": edittype}
> > > return HttpResponse(simplejson.dumps(response_dict), mimetype='text/
> > > javascript')
>
> > > where MyList is a... python list created by:
> > > MyList = []
> > >             for p in packages:
> > >                 MyList.append(p.id)
>
> > > in javascript, I can access the json by:
> > > var obj = YAHOO.lang.JSON.parse(o.responseText);
> > > var PIDS = obj.PackageIDS; //this brings back 3,2 for example, an
> > > array of integers.
>
> > > I cannot get at PIDS as an array in javascript. When I try to convert
> > > to an array, the first item in the array is always all values (3,2)
> > > instead of just the first one (3). The most simplistic attempt at this
> > > was:
>
> > > var jArray = [obj.PythonList]
>
> > > Any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to