因此,控制台显示数据正在发送和接收但由于某种原因(可能是有条件的),在指定的div标签中没有发布任何内容
var var_IDdatacheck = <?php echo $javaid; ?>;
var var_IDcheck = parseInt(var_IDdatacheck);
//datacheck
var var_numdatacheck = <?php echo $datacheck; ?>;
var var_numcheck = parseInt(var_numdatacheck);
function activitycheck() {
$.ajax({
type: 'POST',
url: 'feedupdate.php',
data: {function: '3test', datacheck: var_numcheck, javaid: var_IDcheck},
success: function (check) {
console.log(check);
var verify = JSON.parse(check);
if (var_IDcheck < verify.id) {
var_IDcheck = verify.id;
for (var i=0;i<var_IDcheck;i++){
$('#datacheck').html(verify[i]);
}
}
setTimeout(activitycheck(),5000);
},
error: function(check) {
console.log(check);
setTimeout(activitycheck(),5000);
}
});
}
$(document).ready(function() {
activitycheck();
}); // document ready
答案 0 :(得分:0)
您在JSON中的ID是一个字符串,您将其与整数
进行比较尝试
var verify = JSON.parse(check);
if (var_IDcheck < parseInt(verify.id)) {
var_IDcheck = parseInt(verify.id);
for (var i=0;i<var_IDcheck;i++){