James, First thanks for responding. This formatting is really slowing me down. In answer to your first question, yes the data I'm getting returned is being added successfully to my list in my server -side code (django view). However I don't think I'm formatting stuff correctly because some extra data that I'm adding to the returned data does not appear to be in the right format, when I look at a print of it in my command window. Here's an example of actual data that I've retrieved and am trying to add to my list:
{ u'participations': [], 'status_code': 200, u'page_views': { u'2015-03-01T00:00:00-06:00': 2, u'2015-02-15T20:00:00-06:00': 2, u'2015-02-24T18:00:00-06:00': 2, u'2015-02-15T21:00:00-06:00': 2, u'2015-02-09T01:00:00-06:00': 3, u'2015-02-04T16:00:00-06:00': 3, u'2015-02-16T12:00:00-06:00': 3, u'2015-02-16T04:00:00-06:00': 2, u'2015-02-10T21:00:00-06:00': 2, u'2015-01-27T03:00:00-06:00': 2, u'2015-02-15T04:00:00-06:00': 2, u'2015-02-10T20:00:00-06:00': 4, u'2015-01-15T02:00:00-06:00': 3, u'2015-02-23T02:00:00-06:00': 2 }, 'name': 'Taran Dees', 'id': '5923' } In it all of the data except for status_code, name, and id items that I'm adding, were in the original data returned from my request seems to be in Unicode format. I'm sure my data is the problem since the formatting doesn't look the same here, because the actual data originally returned in json format seems to have all of its keys displaying above in Unicode format. So this is the first thing that I'm pretty sure I need to do to get it at least closer to well-formed json. So presently I'm adding this extra data in a django view with this current code: status_code = json_data.status_code rspnsdata = json.loads(json_data.text) rspnsdata['name'] = str(lstobjct['name']) rspnsdata['id'] = str(lstobjct['id']) rspnsdata['status_code'] = status_code So in the last three statements above I'm unsure how to convert the additional values that I'm adding to the original json data, so that they will be in the proper format, so when I send my final response back to my browser everything will be formatted in well-formed json. In answer to your question about how I'm sending stuff back to an html page I'm using json.dumps to format all of my "response_data" right before I send it back to the "return HttpResponse(response_data, content_type='application/json'), where my javascript will finish parsing and processing it. The actual problem or issue that I'm having is that my javascript is seems to be failing whenever I try to execute the following jQuery/javascript code in my html page: rspdata = jq.parseJSON(data.response_data); And so for that reason I'm thinking I'm not formatting it properly in my view code. I thought I would also, in case it might make a difference, mention that I'm currently using Python 2.7.8, with Django-1.7, and requests-2.4.3 for this application. I would appreciate anything that you can suggest. Thanks. Henry On Monday, March 2, 2015 at 4:38:38 PM UTC-6, James Schneider wrote: > So, do objects ever get successfully added to the list? I had a bit of > trouble following your workflow and figuring out where your issue actually > lives. > > When you say 'send the final list back to an HTML page' do you mean the > Django process is generating the HTML and sending it back as a response to > an AJAX request, or do you mean that Django is responding with a serialized > JSON response, and your JavaScript will handle the HTML formatting of that > data? > > If the former, I would assume that your JS would not need to parse the > HTML returned from the server and would just insert it somewhere into the > page that the user is currently viewing. > > If the latter, are you formatting/serializing the data as JSON yourself? > Or are you serializing it into JSON using the usual Django methods? > > > > Beyond that, what errors are you seeing and where? > > > -James > > > On Mon, Mar 2, 2015 at 10:56 AM, Henry Versemann <fence...@gmail.com > <javascript:>> wrote: > >> I'm trying to submit a series of ajax requests from some server code. >> When I get a response back from each request I'm trying to add that >> response to a list. >> Once all of the requests have been sent and all of their responses >> received and added to the list, then I want to send the final list back to >> an html page for viewing by a user. >> My problem is I can't seem to get the JSON formatting correct either >> before I add each piece of response data to the list, or right before I >> return the list in my HttpResponse so then when it gets sent back to the >> client page my jQuery/javascript cannot parse the data correctly and it >> fails. >> >> Any help would be greatly appreciated. >> >> Thanks. >> >> Henry >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com <javascript:>. >> To post to this group, send email to django...@googlegroups.com >> <javascript:>. >> Visit this group at http://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/ec9be9f3-dd43-4c5c-8649-32c27eb01998%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/ec9be9f3-dd43-4c5c-8649-32c27eb01998%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9643e44b-b3b3-4a16-bfdf-cdbab01e045f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.