On Wed, Jul 3, 2013 at 9:30 AM, C. Kirby <mist...@gmail.com> wrote:
> An HttpResponse includes http headers and will blow up an ajax call.
> You want to use a render_to_string method and pass either json or a rendered
> template (render to string bypasses the headers, render to response will
> include them)

I don't want to return a template, just some data. I tried this:

    return render_to_string(simplejson.dumps(data))

But it blows up with template not found.

> On Wednesday, July 3, 2013 8:14:06 AM UTC-5, larry....@gmail.com wrote:
>>
>> On Tue, Jul 2, 2013 at 5:39 PM, Larry Martell <larry....@gmail.com> wrote:
>> > On Tue, Jul 2, 2013 at 5:24 PM, Sanjay Bhangar <sanjay...@gmail.com>
>> > wrote:
>> >> On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell <larry....@gmail.com>
>> >> wrote:
>> >>>
>> >>> On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar <sanjay...@gmail.com>
>> >>> wrote:
>> >>> > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell <larry....@gmail.com>
>> >>> > wrote:
>> >>> >>
>> >>> >> <snip />
>> >>> >>
>> >>> >> In the browser the response has this:
>> >>> >>
>> >>> >> HTTP/1.0 200 OK
>> >>> >> Date: Tue, 02 Jul 2013 22:53:47 GMT
>> >>> >> Server: WSGIServer/0.1 Python/2.7.2
>> >>> >> Vary: Cookie
>> >>> >> Content-Type: text/plain
>> >>> >>
>> >>> >> No content. But I verified from pdb that the python code is sending
>> >>> >> something in the content when it does this:
>> >>> >>
>> >>> >> return HttpResponse(content=data, content_type="text/plain",
>> >>> >> status=200)
>> >>> >>
>> >>> > try:
>> >>> >   return HttpResponse(data, content_type="text/plain", status=200)
>> >>> >
>> >>> > (no content= ... )
>> >>>
>> >>> No difference - still no content.
>> >>>
>> >> Can you navigate to the page just in the browser (not making an AJAX
>> >> request) ? Do you get a response then? What if you substitute data with
>> >> "some random string" ?
>> >
>> > Yes, I get back the data I expect.
>>
>> I just tried setting an always function and that is called and I can
>> get my response. So I guess I'll go with that. But I wonder why the
>> success function is not called.
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to