window.onload = function() {
alert("This is a onload function ...");
var pass = window.dialogArguments;
var fields = pass.split(/~/);
var userID = fields[0];
$.ajax({
type: "GET",
async: false,
dataType: "JSON",
contentType: 'application/json',
url: "/HostingProject/AdminCustServlet",
data: {ActionType:"1",userID:userID},
success: function(data ,textStatus, jqXHR){
var splitString = data.split('|');
$.each(splitString, function(i, item) {
var tblRow = "<tr>" + "<td>" + item.AccountNumber + "</td>" + "<td>" + item.AccountType + "</td>" + "<td>" + item.AccountStatus + "</td>" + "</tr>";
$(tblRow).appendTo("#Account tbody");
});
}
}
});
return values;
};
我编写了一个ajax函数,我将userID传递给servlet并检索accountno和accountType。我想在jsp页面中显示accountno和帐户类型,但我不能,它不起作用。请帮我。问候, 红宝石
<form action="HostingProject/AdminCustServlet" method="post">
<table id="Account">
<thead>
<tr>
<th>AccountNo</th>
<th>AccountType</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
public void retrieve(HttpServletRequest request){
//TODO Retrieve AccountnNo and AccountType
PrintWriter out = response.getWriter();
SIPAdminCustManager custManager = new SIPAdminCustManager();
System.out.println("manager in retrieve");
int userID = Integer.parseInt(request.getParameter("161"));
List<String> acclist = custManager.retrieveAccountNamebyID(userID);
System.out.println("got acclist"+acclist.size());
Gson gson = new Gson();
String json = gson.toJson(acclist);
response.setContentType("Application/json");
response.getWriter().write(json);
System.out.println("json"+json);
}