My HTML looks like this:
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn").click(function(){
$.post("test.jsp", { "txt": $("#txt").val() },
function(data){
alert(data);
$("#res").html(data);
});
});
});
</script>
It sends the value of the text field "txt"
and then my JSP returns List:
<%
String str=request.getParameter("txt");
List ls=new ArrayList();
ls.add(str+"1");
ls.add(str+"2");
ls.add(str+"3");
ls.add(str+"4");
out.print(ls);
%>
My question is how I can get the list elements one by one? Something like data[1]
.