I tried to loop a JSONArray in my js file, and I have failed. Someone can help me please? this is my servlet code:
ArrayList<Campionato> campionati = DBManager.getInstance().getCampionatoDao().query();
JSONArray jsonArray = new JSONArray(campionati);
resp.getWriter().println(jsonArray);
and this is my Ajax code:
$.ajax({
type: "GET",
url: "MyServlet",
dataType : "json",
success: function(data){
alert("lenght "+ data.length); //this work but if i try data[0] it say me undefined
//I don't know what should I put here for looping
},
error : function(data) {
}
});
thanks all!