$(document).ready(function() {
$(".po").click(function(){
var po = $(this).text();
var dataString = 'po='+ po;
$.ajax
({
type: "GET",
url: "projectitems.php",
data: dataString,
cache: false,
success: function(html)
{
$(this).closest(".resultsItems").html(html);
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
这条线$(this).closest(".resultsItems").html(html);到底是什么意思?我试图将返回的ajax结果附加到一个<td>被调用的.resultsItems,但仅限于初始点击选择器下方的那个?这可能吗?
只是为了说清楚我不是在问这个(这个)在jQuery中意味着什么,我在问我上面的代码中指的是什么(这个)!
this指的是$.ajax()设置对象.要获得您想要的,您需要this使用以下context选项进行维护:
$.ajax({
context: this,
type: "GET",
url: "projectitems.php",
data: dataString,
cache: false,
success: function(html) {
$(this).closest(".resultsItems").html(html);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
230 次 |
| 最近记录: |