In my code I am creating an array-list in JSON and want to response this arraylist into jquery.
List<String> list = new ArrayList<String>();
for(int i=0;i<5;i++){
list.add(i);
}
How can I response this list to my jquery file and get retrieve it in jquery? For a simple String I know how to response and retrieve in jquery using ajax. For example:- IN JSON
String name ="abcd";
writer.key("nameofperson").value(name);
and in jquery
$.ajax({
url: baseURL + '.json',
dataType: 'json',
type:'POST',
success: function(data)
{
console.log("test sucess");
var ROI =data['nameofperson'];
alert(ROI)
},
It is working. How can i acheive the same for arraylist?