Today I was working on JSON.
1) Requirement was to get the data from a server in a JSON object. Store it into request object.
2) And on an HTML page, it was required to fire an AJAX request, get the data from the Servlet created in step 1.
3) When i fired a request to servlet directly in browser window, it used to print JSON object that it returns. But when i make a request thru AJAX call… the data is never displayed.
JSON object must follow the structure of the JSON object.
You cannot add any extra println in the resulting JSP. It must ONLY and ONLY print JSON object.
You can validate your JSON from www.jsonlint.com
See more : http://api.jquery.com/jQuery.ajax/