so, i got 2 pages
index.php:
[code=php]
<script type=”text/javascript” language=”JavaScript”>
<!–
var xmlhttp = false;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
xmlhttp.overrideMimeType(‘text/xml’);
} else if (window.ActiveXObject) {
xmlhttp = new ActiveXObject(” Microsoft.XMLHTTP”);
}
function foo(id) {
if(id !== “”){
document.getElementById(‘result’).innerHTML = “Working…”;
var url = ‘process.php?id=’ + id;
xmlhttp.open(‘GET’, url, true);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById(‘result’).innerHTML = xmlhttp.responseText;
} else {
document.getElementById (‘result’).innerHTML = ”;
}
};
xmlhttp.send(null);
}
}
//–>
</script>
<button onClick=”foo(‘hello’)”>Foo</button><hr>
<div id=”result”></div>
process.php:
[code=php]
POST: <? print_r($_POST) ?>
<br />
GET: <? print_r($_GET) ?>
i click FOO button, executing foo() function,
variable “id” is passes to “process.php” by embeding it in url aka GET method.
i then get results from that “process.php” page and print them into “result” div, which are the following:
[quote]
[b]POST
[b]GET
everything works as expected, but my question is how do i pass variables to the process.php page using POST method? aka so in result div i would get something like:
[quote]
[b]POST
[b]GET
thank you in advance ?