Eccolo:
codice:
function getData(tag, numero){
$.ajax({
type: "POST",
url: "/pagina.php",
data: "tag=" + tag + "&numero=" + numero,
dataType: "json",
success: function(msg)
{
if (msg['risposte'].length > 0){
for (i=0; i<msg['risposta'].length; i++){
t = msg['risposta'][i];
if (i < msg['risposta'].length -1) t +=',';
}
$("#area").append(t + ';\n');
}
if (numero >0 ){
for (i=0; i<msg['tag'].length; i++){
timeoutID = window.setTimeout(getData, 1000 , msg['tag'][i], numero-1);
}
},
error: function()
{
$("#area").append("Errore su " + tag+ "&numero=" + numero + "\n");
}
});
}