我正在尝试在一段时间后更改 div 的内部 HTML。我得到了我想要的 Ajax 的正确响应。但无法用 Ajax 响应替换选定的内部 HTML。我的代码有什么问题..
html
<p class="time ui-li-desc" data-time="2013-02-13 11:30:08" >
51 seconds ago<img alt="image" src="images/read.png"></p>
<p class="time ui-li-desc" data-time="2013-02-13 11:30:16" >
58 seconds ago<img alt="image" src="images/read.png"></p>
.
.
.
.
.
<p class="time ui-li-desc" data-time="2013-02-13 11:40:08" >
10 minute ago<img alt="image" src="images/read.png"></p>
j 查询
setInterval(function() {
$( ".time" ).each(function( index ) {
var sendTime= $(this).attr("data-time");
dataString = "sendtime="+sendTime+"&q=convertTime";
$.ajax({
type: "POST",
url: "data_handler.php",
data: dataString,
cache: true,
success: function(response) {
alert(response);
$(this).html(response);
//alert(response);
}
});
});
}, 5000);