Ciao,
ho scritto un programma che alla richiesta del submit chiede conferma, poi esegue un XMLHttpRequest in modalità sincrona che prepara alcuni dati in un database e al termine del XMLHttpRequest richiama un programma che emette, in una nuova finestra, il risultato dell'elaborazione.
Il mio problema è che mentre il XMLHttpRequest è in esecuzione, rimane visibile la finestra del confirm box, io invece vorrei che questa sparisse appena l'utente ha cliccato ok.
come posso fare?
Questo è il codice:
<form name="form0" method=post action="/cgigrp/rptdsph.cgi" onsubmit="return elabora()"
target="_blank">
<script language=javascript>
function elabora() {
if (confirm('Conferma elaborazione?')) {
pgmtocall = '/cgigrp/vg24rh0a.cgi';
stringpar = 'cgcod=' + document.getElementById("cgcod").value
+ '&keyda=' + document.getElementById("keyda").value
+ '&keyal=' + document.getElementById("keyal").value;
var client = new XMLHttpRequest();
client.open("POST",pgmtocall,false);
client.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
client.send(stringpar);
.....
.....
return true;
}
else {
return false;
}
}
</script>