【发布时间】:2015-03-15 12:25:43
【问题描述】:
这是我在 stackoverflow 中的第一个问题,在我的 html 页面中,我有一个表格,我想使用模态形式将数据发送到 servlet。但是,我有这个错误:Uncaught TypeError: Illegal invocation。
table.html
<body>
<table border="1">
<tr>
<th>ID</th>
<th>NAME</th>
<th>ACTION</th>
</tr>
<tr>
<td>1</td>
<td>JHON</td>
<td><input type="button" value="display" class="d"></td>
</tr>
<tr>
<td>2</td>
<td>Max</td>
<td><input type="button" value="display" class="d"></td>
</tr>
</table>
<div id="dialog-form">
<input type="text" value="" id="id">
<input type="text" value="" id="name">
</div>
<div id="res"></div>
</body>
test.js
$(".d").click(function(){
var id =$("#id").attr("value",$(this).parent().prev().prev().text());
var name =$("#name").attr("value",$(this).parent().prev().text());
$("#dialog-form").dialog({
modal: true,
buttons: {
"Send":function () {
$.post("Controller",{id:id,name:name},function(data){
$("#res").html(data);
}) ;
}
Servlet.java
String name=request.getParameter("name");
String id=request.getParameter("id");
out.println(id +" "+ name);
【问题讨论】:
-
欢迎来到本站。错误发生在哪里?您是否尝试过使用调试器或任何其他研究?另请参阅How to Ask。
-
谢谢,我认为错误在js文件中,函数Send
标签: javascript html servlets