Wednesday, January 12, 2011

One of my application page involves lots of javascript for client side processing. So initially we have added all the related javascript on the html page. This causes huge page size which results slow page response.


So I think to make it dynamic using jQuery. I tried to use jQuery, getJSON method to do it. But it works some times and fails many times. I am using prototype and jQuery both in my application. So I think that this can be the issue as the ajax engine is not able to recognize the request. I further debug this issue and found that ajax engine is not the reason. Even the firebug shows that response is perfect and json is in proper format.

Then I further debug by using the full version of jQuery. I added some alert after analyzing the it. And finally found that jQuery do not show any error message if the json is not in proper format.

I found a site to check the json format after googling. The site is : http://www.jslint.com/. On this site we can verify our json structure.

Then I corrected my json as per the comments from the above site and finally json become perfect and jQuery starts handling the response properly.


The learning from the above scenario are:
  1. The json should be always in proper format.
  2. Verify your json.
  3. Always use double quote (") instead of single quote(').