-2
我有一個getJSON非常大,雖然這加載文檔中的所有數據,當我還沒有加載時如何讀取其他getJSON數據?getJSON異步與獲取 - jquery
中。對事件(被檢測到,但不是的getJSON,只有當其他的getJSON加載所有
$.getJSON('./master-list.php?q=master', function(data) {
$.each(data, function(i, item) {
if(i >= 120)
return false;
addServer(item);
});
});
$(document).on('click', '.servergetid', function() {
console.log('Hey!');
$('#pd').html('');
$.ajax({
url: './data.php?ip=' + $(this).data('server') + '&data=l_by_id',
dataType: 'json',
type: 'GET',
async: true,
success: function(data) {
$.each(data.players, function(i, item) {
$('#pd').append('<tr><td>' + item.Nickname + '</td><td>' + item.Score + '</td></tr>');
});
}
});
});
function addServer(ip)
{
var response = false;
$.getJSON('./data.php?ip=' + ip + '&data=info', function(data)
{
response = addServerInfo(data, '[x]');
});
return response;
}