So, I have a Java Servlet set up to return JSON data in Application/JSON format using the GSON library. The GET method of the Servlet requires an ID parameter. When I send a request with BookingID as 1, Chrome shows the AJAX response like this:
0: {WidgetID:46, BookingID:1, X:393, Y:50, Content:Test1}
1: {WidgetID:47, BookingID:1, X:337, Y:251, Content:Test2}
2: {WidgetID:48, BookingID:1, X:97, Y:198, Content:Test3}
The issue I'm facing is how to properly parse this response in my JavaScript code. Here's what I currently have:
loadPositions() { var BookingID = if (BookingID != null && BookingID != "null") { var data = {"id" : BookingID}; $.getJSON("Widget", data, function(data) { // Successfully got all this bookings widgets as JSON, TODO: Parse this! }); } }
What should I do in the "TODO: Parse this!" section? I need to loop through each element and extract their data. Any help on jQuery would be greatly appreciated.