0
私はこの言語を使い慣れていますが、現在いくつかのテストを行っています 下の画像で編集をクリックすると editImage私は別のページ にリダイレクトされませんが、私は以下のように開発者のツールでパラメータを見ることができます image。
私はupdatePersonの機能でそれを行う方法を知っていますか?私は、私だけが更新されたデータを渡す
function updatePerson(id) {
$.post("update.jsp",
{id: id}
, function (result) {
**$("#resultDiv").html(result);**
});
}
以下のようなコードを使用して、同じページでそれを示して別のページにリダイレクトするのではなく、
<%@page import="Entities.Person.Person"%>
<%@page import="java.util.List"%>
<%@page import="Entities.Person.PersonSessionBeanLocal"%>
<%@page import="javax.naming.InitialContext"%>
<script type="text/javascript">
function updatePerson(id) {
$.post("updatePerson.jsp",
{id: id}
, function (result) {
});
}
</script>
<%
try {
InitialContext ctx = new InitialContext();
PersonSessionBeanLocal personBean = (PersonSessionBeanLocal) ctx.lookup("java:comp/env/person");
String keyword = request.getParameter("keyword");
List<Person> resList = personBean.searchPerson(keyword);
out.print("<table border='1' width='100%'>"
+ "<tr>"
+ "<th>ID</th>"
+ "<th>Name</th>"
+ "<th>Description</th>"
+ "<th colspan='2'>Actions</th>"
+ "</tr>"
);
for (Person p : resList) {
//out.print(p.toString() + "<br/>");
out.print("<tr>"
+ p.toString()
//+"<td><input type='button' name='edit' id='edit' value='Edit' onclick='editPerson(" + p.getId() + ")' style='width:100%'></td>"
+ "<td><input type='button' name='edit' id='edit' value='Edit' onclick='updatePerson(" + p.getId() + ")' style='width:100%'></td>"
+ "<input id='hiddenID' name='hiddenID' type='hidden' value='" + p.getId() + "'>"
+ "<input id='hiddenName' name='hiddenName' type='hidden' value='" + p.getName() + "'>"
+ "<input id='hiddenDesc' name='hiddenDesc' type='hidden' value='" + p.getDescription() + "'>"
+ "<td><input type='button' name='delete' id='delete' value='Delete' onclick='deletePerson(" + p.getId() + ")' style='width:100%'></td>"
+ "</tr>"
//+ "</table>"
);
}
out.print("</table>");
} catch (Exception e) {
e.printStackTrace();
}
%>
リダイレクトしたい場合は** do not do ajax – madalinivascu
どのページをリダイレクトしますか?ページに送信されるデータはありますか? –