function ajaxRequest() { var xmlhttp = null; try { xmlhttp = new XMLHttpRequest(); } catch (e1) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e2) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e3) { xmlhttp = null; } } } return xmlhttp; } Chiamata: function controllaDocumento() { var xmlhttp = ajaxRequest(); if (xmlhttp == null) { alert(\'Browser non supportato.\'); return; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // xmlhttp.responseText contiene l\'output dell\'agente // Per semplificare potresti fare in modo che l\'agente ritorni: // 1 se il controllo è stato passato con successo // 0 se il controllo non è stato superato // quindi: if (xmlhttp.responseText != \'1\') { alert(\'Documento non valido\'); } } }; xmlhttp.open(\'GET\', \'nomeagente?OpenAgent¶m1=x¶m2=y); xmlhttp.send(null); } }
Massimo Nadalin | Devangarde
|