尝试
$(document).ready(function(){
async().then(fetch);
});
function fetch(){
setTimeout(function(){
async().then(fetch);
}, 5000);
}
function async(){
return $.ajax({
type: 'GET',
url: 'message.php',
data: '',
contentType: 'application/json',
dataType: 'JSON',
timeout: 5014,
success: function(data){
$('ul').children().remove();
$.each(data, function(index, item){
$('#lstip').append('
'+item.ip+'');$('#lstmsg').append('
'+item.message+'');$('#lstlike').append('
'');});
},
error: function(xhr, stats, err){
console.log(stats);
}
});
}
$(document).ready(function(){
async().then(fetch);
});
function fetch(){
setTimeout(function(){
async().then(fetch);
}, 5000);
}
function async(){
return $.ajax({
method: 'GET',
url: 'https://api.github.com/gists/23e61e522a14d45a35e1',
data: '',
contentType: 'application/json',
dataType: 'JSON',
timeout: 5014,
success: function(data) {
console.log(JSON.parse(data.files["a.json"].content));
// $('ul').children().remove();
// $.each(data, function(index, item){
// $('#lstip').append('
'+item.ip+'');// $('#lstmsg').append('
'+item.message+'');// $('#lstlike').append('
'');// });
},
error: function(xhr, stats, err){
console.log(stats);
}
});
}