JSON parse error, unexpected character

503 views
Skip to first unread message

Prashant Jain

unread,
Oct 2, 2012, 6:27:11 PM10/2/12
to js-test...@googlegroups.com
I keep getting the above error. There are times when I don't get this error but most of the time I do. Please see the attached screen shot.

I have recommended JSTestDriver to my team. But I am now noticing that it is unstable and unpredictable. My stubbed functions are called and sometimes they are not. I get the JSON parse error and sometimes I don't. 

I am almost at a point where I am exploring headless QUnit. 
Screen shot 2012-10-02 at 3.13.30 PM.png

Cory Smith

unread,
Oct 3, 2012, 6:40:58 PM10/3/12
to js-test...@googlegroups.com
The screenshot really isn't helpful for reproduction. Do you have anything else?
> --
> You received this message because you are subscribed to the Google Groups
> "JsTestDriver" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/js-test-driver/-/m2bfROF3A5AJ.
> To post to this group, send email to js-test...@googlegroups.com.
> To unsubscribe from this group, send email to
> js-test-drive...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/js-test-driver?hl=en.

Vitali S.

unread,
Mar 21, 2013, 8:57:55 AM3/21/13
to js-test...@googlegroups.com
Hi,

I think the problem is the content to are going to parse into a JSON object. Try it with some other content.
Please see the following post http://stackoverflow.com/questions/9492916/putting-html-in-json
and also http://www.json.org/

Vitali

Cory Smith

unread,
Mar 21, 2013, 9:04:05 AM3/21/13
to js-test...@googlegroups.com
It's more of a question about *when* it happens. I still need more
information to reproduce the issue.
> --
> You received this message because you are subscribed to the Google Groups
> "JsTestDriver" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to js-test-drive...@googlegroups.com.
>
> To post to this group, send email to js-test...@googlegroups.com.
> Visit this group at http://groups.google.com/group/js-test-driver?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Baz

unread,
Mar 21, 2013, 1:12:10 PM3/21/13
to js-test...@googlegroups.com
It's pretty obvious from that screenshot (if you've messed with web
services before). It's trying to parse json, but "data" is html (not
json with html in it - it's just html). The most common cause of this
is serving json from an endpoint where all the error responses (404,
500, etc) are html, and the js handling the response ignores the code;
or worse, that errors are funneled through an error page which serves
a 200 response code.

So the wrong thing is being passed into jQuery.parseJSON(data). What's
the stacktrace? Have you looked at the content of 'data' to see what
html you were trying to parse? I'm guessing it's going to be an error
page and its contents will be a big clue as to what's wrong here.

-B
Reply all
Reply to author
Forward
0 new messages