刷新行并将行的两列替换为来自操作类的响应
Refreshing the row and replacing the two columns of a row with the responsegot from action class
我在jsp页面中有表格,每行都有刷新按钮,并且单击每个刷新按钮我有一个javascript/ajax调用,其中它将转到操作类并获取状态和 #records 的值,并将列替换为相应行的检索数据
这是我的 jsp 表:
<table border="1" class="displaytab" id="rtable">
<s:if test="%{user.roles == 'admin'}">
<tr> <td colspan="10" style="background:#7395B8;color:white;font-size:18px;font-weight:bold;"><center>Admin</center></td></tr>
</s:if>
<tr>
<th>FileId</th><th>File Name</th><th>Upload Date</th><th>#Records</th><th>Status</th><th>Estimated Time</th><th>Processed Records</th><th>Generate Report</th><th></th><s:if test="%{user.roles == 'admin'}"><th>Controls</th></s:if>
</tr>
<s:iterator value="uploadList" var="m">
<tr>
<td><s:property value="%{#m.fileId}" /></td>
<td><s:property value="%{#m.fileName}" /></td>
<td><s:property value="%{#m.uploadDate}" /></td>
<td><div id="div2"><s:property value="%{#m.numRecords}" /></div></td>
<td><div id="div1"><s:property value="%{#m.status}" /></div></td>
<td>tbd</td>
<td><s:property value="%{#m.numRecords}" /></td>
<td><a href=""><img src="images/generate.png" title="Generate Report"></a></td>
<td><a href=""><img src="images/refresh.png" title="Refresh" id="refresh" onclick="refreshRecord(<s:property value="%{#m.fileId}" />);"></a></td>
这是我使用 Ajax 的 JavaScript:
var id;
function refreshRecord(value)
{
id = value;
alert(id);
}
$(document).ready(function(){
$("#refresh").click(function(){
var fileId=id;
alert("ajax id is "+fileId);
var rowNum = $(this).parent().parent().index();;
alert(rowNum);
$.ajax({
type:"post",
url:"checkStatusAndNumRecs",
data:{fileId:fileId},
success:function(data)
{
setTimeout(alert(data), 2000);
var allTds = $("#rtable tr:eq('"+rowNum+"')").find('td');
$(allTds)[4].html(data[0]);
$(allTds)[3].html(data[1]);
},
error:function(data)
{
$("#div1").html("It was a failure !!!");
}
});
});
});
</script>
这是我的操作类"checkStatusAndNumRecs"公共字符串执行() {
System.out.println("here inside action-------------");
PersistenceService svc = PersistenceServiceImpl.getInstance();
status = svc.getStatusByFileId(fileId);
System.out.println("status is "+status);
numRecords = svc.getNumRecordsByFileId(fileId);
System.out.println("num records are "+numRecords);
return "SUCCESS";
}
我正在运行这个,在操作类中我正在获得状态和数字记录,问题是
只为第一行ajax函数在调用,其余行它不会进入ajax函数内部
我没有在 ajax 中获得状态和数字记录
3.datafrom Action 类应替换为"状态"和"#records"两列。请任何身体帮忙,我从几天开始就为此挣扎。
而且我没有使用 servlet,并且在表中我正在迭代数据列表。
我也遇到了这样的问题,我认为你的问题出在你的html表中。您已将刷新按钮放在表中。当 ajax 来到你的刷新按钮时,它无法读取按钮,并且发生异常,而不是不传递下一行。
相关文章:
- 无法从 jQuery RSS Feed 中的 localStorage 动态替换类
- jquery操作与匹配项在替换
- 我正在尝试使用JS/JQuery自动对网站中的文本执行多个查找和替换操作
- 在替换之前,操作javascript正则表达式匹配,例如$1
- nodejs:原子文件替换操作,只触发一次一些观察者
- 替换“单击时”操作以显示内联输出
- 替换超链接默认操作以加载 AJAX 请求
- JS 字符串格式化操作 - 将变量值替换为字符串
- 刷新行并将行的两列替换为来自操作类的响应
- JavaScript/jQuery操作然后替换我的HTML内容中的所有链接
- 如何在 JavaScript 中用 DOM 操作函数替换元素内容
- 如何使用javascript/jQuery替换onclick操作(使用regex)
- 根据用户的操作或按钮点击,用另一个替换子反应组件
- 对组捕获进行字符串替换和操作
- 如何将ONCLICK替换为在一段时间内执行的自动操作
- Javascript字符串操作-小写,替换,修剪,分割
- 字符串操作,替换"“;(空间)
- 在搜索操作期间无法替换文本
- 将javascript中的线性字符串替换操作更改为数组
- ActiveX组件-文字操作替换