我尝试对表中的每一行执行 Ajax 请求,但无法达到预期的结果
桌子:
<table>
<tr class="data">
<td class="editable">
<a class="refresh btn btn-large" class="page">
Col one
</a>
</td>
<td class="editable">
<a href="#" data-pk="10" id="query" class="query">
Col two
</a>
</td>
</tr>
<tr class="data">
<td class="editable">
<a class="refresh btn btn-large" class="page">
Col one 1
</a>
</td>
<td class="editable">
<a href="#" data-pk="10" id="query" class="query">
Col two 1
</a>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
Ajax 请求
$("#detect_rel").click(function(){
$('.data').each(function(i, el) {
var query = $(el).children('.editable').children('.query').text();
var page = $(el).children('.editable').children('.page').text();
$.ajax({
url: 'wordstat/ajax?query='+query+'&page='+page,
success: function(data){
$(el).children('.editable').children('.relevantnost').html(data)
}
}); …Run Code Online (Sandbox Code Playgroud) 我找到了很多关于我的问题的答案,但问题没有解决
我有表格,有数据,例如:
<table>
<tr>
<td class="editable"> <a id="query" href="#"> Data 1 </a> </td>
<td class="editable"> <a id="text" href="#"> Data 2 </a> </td>
<td class="editable"> <a id="foo" href="#"> Data 3 </a> </td>
<td class="editable"> <a id="bar" href="#"> Data 4 </a> </td>
</tr>
<tr>
<td class="editable"> <a id="query" href="#"> Data 1 </a> </td>
<td class="editable"> <a id="text" href="#"> Data 2 </a> </td>
<td class="editable"> <a id="foo" href="#"> Data 3 </a> </td>
<td class="editable"> <a id="bar" href="#"> Data 4 </a> </td>
</tr>
</table> …Run Code Online (Sandbox Code Playgroud)