I wrote an app that will pass data via JSON. It is cross domain so I am using jQuery JSONP. My page works great when hitting this JSON echo site: http://echo.jsontest.com/key/value/one/two But when I hit my simple Java app, I get a jQuery parse error.
This is my basic condensed Java code:
I have tried every conceivable variation but still I get a parse error. When I hit the servlet directly, I see this which looks okay to me.
What can I try or do to make this work? What is the echo test site doing that I'm not doing in Java?
In "normal" JSON the opening ( and trailing ); are not part of JSON. But with JSONP, you essentially create a function call. Your response appears to be missing the callback name (which should precede the opening paren).
Advice: don't create JSON by hand. Use a JSON library such as Gson or Jackson.