E
eddie
I have a form. The form submits correctly and the php script GET's the
?variables=whatever&variables2=whatever2, but when I try and use AJAX,
I receive no errors, my innerHTML is changed with the responsetext, but
my php script never receives the GET variables. Here is the php script:
<?php
// Host/IP
$host = $_REQUEST['host'];
// Start Port
$port = $_REQUEST['port'];
if(empty($host) && empty($port)) { echo "host and port are both
empty!"; exit(); }
?>
I use an onclick with an img to call the function:
SetInnerHTMLFromAJAX('connect.php','myobj');
//ajax.js--------------------------------------
// Get a browser independent XMLHTTP Object
function GetXMLHTTP() {
var XMLHTTP = false;
if (window.XMLHttpRequest) {
XMLHTTP = new XMLHttpRequest()
} else if (window.ActiveXObject) {
try {
XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP")
} catch (E) {
XMLHTTP = false;
}
}
}
return XMLHTTP;
};
// Pass a server side response as a javascript function
function SetInnerHTMLFromAJAX(url, obj_id) {
var XMLHTTP = new GetXMLHTTP();
// Send the Request
if (XMLHTTP) {
XMLHTTP.onreadystatechange = function stateChange() {
if (XMLHTTP && XMLHTTP.readyState == 4) {
// Got something back..
if (XMLHTTP.status == 200) {
// Check to see if the response was good
var response = XMLHTTP.responseText;
if(debug) {
alert(response);
}
document.getElementById(obj_id).innerHTML = response;
} else if(debug){
document.write(XMLHTTP.responseText);
}
}
}
// open the page
XMLHTTP.open("GET", url, true);
// send the data
XMLHTTP.send(null);
}
}
// end ajax.js
Anyone have any idea why my ajax is not passing the get variables to
the php $_REQUEST?
?variables=whatever&variables2=whatever2, but when I try and use AJAX,
I receive no errors, my innerHTML is changed with the responsetext, but
my php script never receives the GET variables. Here is the php script:
<?php
// Host/IP
$host = $_REQUEST['host'];
// Start Port
$port = $_REQUEST['port'];
if(empty($host) && empty($port)) { echo "host and port are both
empty!"; exit(); }
?>
I use an onclick with an img to call the function:
SetInnerHTMLFromAJAX('connect.php','myobj');
//ajax.js--------------------------------------
// Get a browser independent XMLHTTP Object
function GetXMLHTTP() {
var XMLHTTP = false;
if (window.XMLHttpRequest) {
XMLHTTP = new XMLHttpRequest()
} else if (window.ActiveXObject) {
try {
XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP")
} catch (E) {
XMLHTTP = false;
}
}
}
return XMLHTTP;
};
// Pass a server side response as a javascript function
function SetInnerHTMLFromAJAX(url, obj_id) {
var XMLHTTP = new GetXMLHTTP();
// Send the Request
if (XMLHTTP) {
XMLHTTP.onreadystatechange = function stateChange() {
if (XMLHTTP && XMLHTTP.readyState == 4) {
// Got something back..
if (XMLHTTP.status == 200) {
// Check to see if the response was good
var response = XMLHTTP.responseText;
if(debug) {
alert(response);
}
document.getElementById(obj_id).innerHTML = response;
} else if(debug){
document.write(XMLHTTP.responseText);
}
}
}
// open the page
XMLHTTP.open("GET", url, true);
// send the data
XMLHTTP.send(null);
}
}
// end ajax.js
Anyone have any idea why my ajax is not passing the get variables to
the php $_REQUEST?