Tuesday, September 1, 2009

[jQuery] Re: not returning a JSON object

What happens if you change the type to "text/html"? (or not force any
types.)

On Sep 1, 1:03 am, defdev <sp...@definitivedevelopment.co.uk> wrote:
> Nick,
>
> thanks, but that didnt solve it either.
>
> return from the ajax/form submit:
>
> # alert(json);
> { "message": "why wont this work" }
>
> # alert(json.message);
> undefined
>
> in firebug, the headers are correct (application/json) - im struggling
> to see whats wrong?
>
> On Sep 1, 11:55 am, Nick Fitzsimons <n...@nickfitz.co.uk> wrote:
>
> > 2009/8/27 defdev <sp...@definitivedevelopment.co.uk>:
>
> > > from the server side:
>
> > >  echo '{ message: "why wont this work" }';
>
> > That isn't valid JSON. According to the JSON spec <http://json.org/>,
> > the name part of a name: value pair needs to be quoted with double
> > quotes, and a strict JSON parser will enforce this. Changing it to
>
> > echo '{ "message": "why wont this work" }';
>
> > will fix it.
>
> > Of course this may not actually fix your problem - I'm not sure how
> > strict jQuery is about enforcing JSON parsing rules - but fixing it
> > will eliminate one possible point of failure.
>
> > Regards,
>
> > Nick.
> > --
> > Nick Fitzsimonshttp://www.nickfitz.co.uk/
>
>

No comments: