cody7 Posted February 20, 2008 Share Posted February 20, 2008 Hi guys i can't get this to work this is the onclick function function process() { // only continue if xmlHttp isn't void if (xmlHttp) { // try to connect to the server try { var firstNumber = document.getElementById("firstNumber").value; var secondNumber = document.getElementById("secondNumber").value; // ($_POST) var params = "firstNumber=" + firstNumber + "&secondNumber=" + secondNumber; xmlHttp.open("POST", "compute.php", true); xmlHttp.onreadystatechange = handleRequestStateChange; xmlHttp.send(params); } // display the error in case of failure catch (e) { alert("Can't connect to server:\n" + e.toString()); } } } and this will be the compute.php header('Content-Type: text/xml'); $firstNumber = $_POST['firstNumber']; $secondNumber = $_POST['secondNumber']; ..... my problem I tried the GET approach and I make it to work so now Im trying the POST approach but $firstNumber and $secondNumber is not getting any value. can't figure out what went wrong. please help Link to comment https://forums.phpfreaks.com/topic/92125-xmlhttpopen/ Share on other sites More sharing options...
Ken2k7 Posted February 21, 2008 Share Posted February 21, 2008 Hello, You need to set some RequestHeaders to use POST. Ken Link to comment https://forums.phpfreaks.com/topic/92125-xmlhttpopen/#findComment-473086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.