Re: Returning data from view to ajax call

2013-07-03 Thread Larry Martell
On Wed, Jul 3, 2013 at 10:01 AM, C. Kirby wrote: > I'm sorry, I was typing without thinking. > render_to_string() if you want to use a template without headers > render_to_response() includes headers > > HttpResponse(json.dumps(data_object)) should be what you want. > > It would also be helpful to

Re: Returning data from view to ajax call

2013-07-03 Thread C. Kirby
I'm sorry, I was typing without thinking. render_to_string() if you want to use a template without headers render_to_response() includes headers HttpResponse(json.dumps(data_object)) should be what you want. It would also be helpful to see the code for your view. It looks like you already put th

Re: Returning data from view to ajax call

2013-07-03 Thread Larry Martell
On Wed, Jul 3, 2013 at 9:30 AM, C. Kirby 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

Re: Returning data from view to ajax call

2013-07-03 Thread C. Kirby
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) On Wednesday, July 3, 2013 8:14:06 AM UTC-5, larry@gmail.co

Re: Returning data from view to ajax call

2013-07-03 Thread Larry Martell
On Tue, Jul 2, 2013 at 5:39 PM, Larry Martell wrote: > On Tue, Jul 2, 2013 at 5:24 PM, Sanjay Bhangar > wrote: >> On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell >> wrote: >>> >>> On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar >>> wrote: >>> > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell >>> >

Re: Returning data from view to ajax call

2013-07-02 Thread Larry Martell
On Tue, Jul 2, 2013 at 5:24 PM, Sanjay Bhangar wrote: > On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell > wrote: >> >> On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar >> wrote: >> > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell >> > wrote: >> >> >> >> >> >> >> >> In the browser the response has t

Re: Returning data from view to ajax call

2013-07-02 Thread Sanjay Bhangar
On Tue, Jul 2, 2013 at 4:20 PM, Larry Martell wrote: > On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar > wrote: > > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell > > wrote: > >> > >> > >> > >> In the browser the response has this: > >> > >> HTTP/1.0 200 OK > >> Date: Tue, 02 Jul 2013 22:53:47 GM

Re: Returning data from view to ajax call

2013-07-02 Thread Larry Martell
On Tue, Jul 2, 2013 at 5:14 PM, Sanjay Bhangar wrote: > On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell > wrote: >> >> >> >> 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: te

Re: Returning data from view to ajax call

2013-07-02 Thread Sanjay Bhangar
On Tue, Jul 2, 2013 at 4:01 PM, Larry Martell wrote: > > 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

Re: Returning data from view to ajax call

2013-07-02 Thread Larry Martell
On Tue, Jul 2, 2013 at 4:49 PM, Sanjay Bhangar wrote: > On Tue, Jul 2, 2013 at 3:37 PM, Larry Martell > wrote: >> >> On Tue, Jul 2, 2013 at 4:24 PM, Sithembewena Lloyd Dube >> wrote: >> > What data format is your view returning? Django views return HTTP >> > response >> > objects (by default, at

Re: Returning data from view to ajax call

2013-07-02 Thread Sanjay Bhangar
On Tue, Jul 2, 2013 at 3:37 PM, Larry Martell wrote: > On Tue, Jul 2, 2013 at 4:24 PM, Sithembewena Lloyd Dube > wrote: > > What data format is your view returning? Django views return HTTP > response > > objects (by default, at least) - although Python lists (and other Python > > collections?) s

Re: Returning data from view to ajax call

2013-07-02 Thread Larry Martell
On Tue, Jul 2, 2013 at 4:24 PM, Sithembewena Lloyd Dube wrote: > What data format is your view returning? Django views return HTTP response > objects (by default, at least) - although Python lists (and other Python > collections?) should work when passed into a view in its context (I have > found

Re: Returning data from view to ajax call

2013-07-02 Thread Sithembewena Lloyd Dube
What data format is your view returning? Django views return HTTP response objects (by default, at least) - although Python lists (and other Python collections?) should work when passed into a view in its context (I have found Django querysets to be an exception). AJAX is Asynchronous Javascript,

Returning data from view to ajax call

2013-07-02 Thread Larry Martell
I'm invoking a view from an ajax call and I want to return data. But the browser interpertates the return as a 500 (internal sever error) and my ajax success function does not get called. How can I return a successful status (like a 201) and also return data? -- You received this message because