Jump to content

xmlHttp.open


cody7

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.