I have a problem with the getJson callback in jquery. Here's the
scneario. The user enters a query online and hits 'execute'. At this
point make a call to a java servlet that returns the results of the
query. The results include one row contiaing the column names which is
followed by multiple rows of data. The results are formatted and
returned as a Json to the javascript. The problem is I am not able to
see any alerts put within the $getJson callback function. I think it
is failing silently, but I'm not able to figure out why. Please help!

Here's the sample data returned:

{"results":{

        "columnNames":[ "productCode",
                        "productName",
                        "productLine",
                        "productScale",
                        "productVendor",
                        "productDescription",
                        "quantityInStock",
                        "buyPrice",
                        "MSRP"],
        "values":[
                        ["S10_1678",
                        "1969 Harley Davidson Ultimate Chopper",
                        "Motorcycles",
                        "1:10",
                        "Min Lin Diecast",
                        "This replica features working kickstand, front 
suspension, gear-
shift lever, footbrake lever, drive chain, wheels and steering. All
parts are particularly delicate due to their precise scale and require
special care and attention.",
                        "7933",
                        "48.81",
                        "95.7"],

                        ["S10_1949",
                        "1952 Alpine Renault 1300",
                        "Classic Cars",
                        "1:10",
                        "Classic Metal Creations",
                        "Turnable front wheels; steering function; detailed 
interior;
detailed engine; opening hood; opening trunk; opening doors; and
detailed chassis.",
                        "7305",
                        "98.58",
                        "214.3"],

                        ["S10_2016",
                        "1996 Moto Guzzi 1100i",
                        "Motorcycles",
                        "1:10",
                        "Highway 66 Mini Classics",
                        "Official Moto Guzzi logos and insignias, saddle bags 
located on
side of motorcycle, detailed engine, working steering, working
suspension, two leather seats, luggage rack, dual exhaust pipes, small
saddle bag located on handle bars, two-tone paint with chrome accents,
superior die-cast detail , rotating wheels , working kick stand,
diecast metal with plastic parts and baked enamel finish.",
                        "6625",
                        "68.99",
                        "118.94"],

                        ["S10_4698",
                        "2003 Harley-Davidson Eagle Drag Bike",
                        "Motorcycles",
                        "1:10",
                        "Red Start Diecast",
                        "Model features, official Harley Davidson logos and 
insignias,
detachable rear wheelie bar, heavy diecast metal with resin parts,
authentic multi-color tampo-printed graphics, separate engine drive
belts, free-turning front fork, rotating tires and rear racing slick,
certificate of authenticity, detailed engine, display stand, precision
diecast replica, baked enamel finish, 1:10 scale model, removable
fender, seat and tank cover piece for displaying the superior detail
of the v-twin engine",
                        "5582",
                        "91.02",
                        "193.66"],

                        ["S10_4757",
                        "1972 Alfa Romeo GTA",
                        "Classic Cars",
                        "1:10",
                        "Motor City Art Classics",
                        "Features include: Turnable front wheels; steering 
function;
detailed interior; detailed engine; opening hood; opening trunk;
opening doors; and detailed chassis.",
                        "3252",
                        "85.68",
                        "136"]

                ]
        }
}


Since I am new to JSON, I thought it might be a problem with the
formatting. So, I validated the above at www.jsonlint.com and it came
out as a valid json.

Here's the callback

var queryText = $('#query_text').val();
if (!(queryText == null))
{
        $.getJSON("qtool", {action : "executeQuery", entity_name :
queryText },
                function (data)
                {
                        alert("test3");
                }
        );
}

Thanks in advance!!

Reply via email to