1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
function go2(){
var xhr = getXhr(); // ici j'appel une fonction qui me creer un object XMLHttpRequest()
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4 && xhr.status == 200)
{
reponse = xhr.responseText;
var tableau2 = reponse.split(' ');
document.getElementById('format_field').value = tableau2[0];
}
}
// Ici on va voir comment faire du post
xhr.open("POST","format_champs.php",true);
// ne pas oublier ça pour le post
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
// ne pas oublier de poster les arguments
var sel = document.getElementById('Champs');
inde = sel.options[sel.selectedIndex].value;
xhr.send("inde="+inde);
} |
Partager