我正在使用 ajax 和 php 脚本开发我的网站。我的网页被以下 ajax 脚本挂起。我应该如何修改脚本以避免挂起
<script>
$(function(){
$('#popModal_ex2').click(function(){
$('#popModal_ex2').popModal({
html : function(callback) {
setInterval(function() {
$.ajax({url:'notification_message.php'}).done(function(content){
callback(content);
}, 4);
});
}
});
});
});
</script>
最佳答案
挂起的原因是 setInterval() 缺少第二个参数,它将“每秒”执行 ajax 调用
$('#popModal_ex2').click(function(){
$('#popModal_ex2').popModal({
html : function(callback) {
setInterval(function() {
$.ajax({
url:'notification_message.php',
}).done(function(content){
callback(content);
});
}, 6000); // every 6 second
}
});
});
关于javascript - Ajax 挂了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24582981/