/ / getJSON async mit get - jquery - javascript, jquery

getJSON async mit get - jquery - javascript, jquery

Ich habe einen sehr großen getJSON, und während dies alle Daten in das Dokument lädt, wie kann ich andere getJSON-Daten lesen, während dies noch geladen wird?

Das Ereignis in .on (wird erkannt, aber der getJSON nicht), wird nur erkannt, wenn der andere getJSON alle geladen ist

    $.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;
}

Antworten:

0 für die Antwort № 1

Vergiss es, die Lösung ist async ändern: true to async: false, danke.