【发布时间】:2016-09-05 06:20:22
【问题描述】:
我通过脚本中的 ajax 调用将字符串值传递给 servlet,并在类对象中检索相应的数据并将其存储在 arraylist 中。现在我需要这个数组列表作为返回给 ajax 调用的“数据”。怎么做??
`<script>
$(document).ready(function(){
var selected;
$('#txtboxvalue').change(function(){
selected = $('#txtboxvalue').val();
$.ajax({
url: "Servlet2",
type: "Post",
data: {"txtboxvalue":selected},
success : function(data)
{
//here is where I want to access the returned arraylist
}
});
});
</script>
小服务程序:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ArrayList<Cust> list2=cusName.dispCustomer2(abcd);
PrintWriter out = response.getWriter();
out.println(list2);
}
但是这样传递是行不通的
【问题讨论】:
-
同时检查数据类型
标签: java jquery json ajax arraylist