var xhr = new XMLHttpRequest(); xhr.open("POST", action, true); /* 1 */ xhr.setRequestHeader ( "Content-type", "application/x-www-form-urlencoded"); xhr.send ( str ); /* 2 */ xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { /* 3 */ } };
var wert1 = "Für den Server", wert2 = "nochwas"; var str = 'NAME1=' + wert1 + '&NAME2=' + wert2;
alert(responseText);