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 和 account type,但我不能,而且它不起作用。请帮我。问候, 红宝石
<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);
}