jQuery shines when it comes to AJAX transactions - you can get a JSON result from a web service using one instruction! Going over the reply is also a snatch. I found myself many times just needing to dump the results on the page - either for debugging purposes, or so I could copy/paste them somewhere.
Here is a short code snippet that I use to get a JSON result from a local web service (a remote request requires JSONP - future post), and dumps the results in a form of a list. It assumes a single-level array reply and that you have a <DIV> element on the page called "result":
- Line 1 includes version 1.5.2 of jQuery from the Microsoft CDN
- Line 4 will make sure the function will run when the document has been fully loaded and drawn
- Line 5 calls the JSON service and sends the results to a function
- Line 8 iterates over the result object and creates an array of <LI> elements
- Line 14 creates a new <UL> element, applies a CSS style to it, attaches the <LI> elements and places it inside the result <DIV>