I am using ColdFusion 9.0.1 and jQuery 1.6.2.
I am doing an call using CFAJAXPROXY and jQuery like this:
var jro = new jsApp();
MyResults = jro.getProductPricing(CustomerID, OrderID, ProductID);
I will always get one result back. Here is a sample of the result I get back:
{"COLUMNS":["PRICE","POINTS","BV","DESCRIPTION"],"DATA":[[14.990000,6.8,6.00,"CLEAR VANILLA 11OZ-325ML"]]}
When I get this result back, I need to parse it and populate spans within the page.
I have never tried to parse JSON like this. This seems like it should be very simple to parse, but every example I see makes it look like rocket science. How to I use jQuery to get at the PRICE, POINTS, BV, and DESCRIPTION columns? Is there a bad way to do this? What’s a good way?
There’s
setQueryFormat('column')that you can call before invoking the webservice so that the resulting JSON object is easier to access or manipulate, but the down side of this is the resulting JSON string will be bigger because the column names are repeated for every record in the recordset.CF Dev Doc: Using data interchange formats
-> Controlling CFC remote return value data format