E
Eric Wallstedt
I have a page that "logs" changes made to input fields using ajax to
pass data to a cgi. I use POST and it works fine most of the time (all
the time in IE). But it fails when I get the data from a popup that
invokes a function that in turn invokes ajax.
Scenerio
1. user clicks a button to create a popup
2. the user selects a select member and clicks a button and a
function in the calling page is invoked.
3. the ajax function is invoked and the data is passed to the cgi.
if it works I get:
request sent to server... 1... 2... 3... 4... 2006-02-17
13:28:47.491131|id:2097|name:dept|seq:0|value:53
when it fails I get:
request sent to server... 1... 2... 4...
where the 1... 2... 3... 4.... are the readyStates
Any ideas?
function rt_AJAX(req) {
document.getElementById("message").value = " request sent to
server... ";
xmlhttpPost(req);
}
function xmlhttpPost(req) {
var xmlHttpReq = false;
req.s1=true;
req.s2=true;
req.s3=true;
req.s4=true;
// IE
if (window.ActiveXObject) {
var xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
// Mozilla/Safari
else {
var xmlHttpReq = new XMLHttpRequest();
xmlHttpReq.overrideMimeType('text/xml');
}
xmlHttpReq.open('POST', req.url, true);
xmlHttpReq.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 1) { req.s1=false; }
if (xmlHttpReq.readyState == 2) { req.s2=false; }
if (xmlHttpReq.readyState == 3) { req.s3=false; }
if (xmlHttpReq.readyState == 4) { req.s4=false; }
document.getElementById("message").value += xmlHttpReq.readyState
+ "... ";
if (xmlHttpReq.readyState == 4) {
try {
req.str=xmlHttpReq.responseText;
}
catch(e) {
req.str=e;
}
updatepage(req);
if (req.s1 || req.s2 || req.s3 || req.s4) {
alert('Update Failed on the Server ("'+req.name+'")
Discontinue Use and Contact XXXXXXXXX');
}
}
}
xmlHttpReq.send(getquerystring(req));
}
pass data to a cgi. I use POST and it works fine most of the time (all
the time in IE). But it fails when I get the data from a popup that
invokes a function that in turn invokes ajax.
Scenerio
1. user clicks a button to create a popup
2. the user selects a select member and clicks a button and a
function in the calling page is invoked.
3. the ajax function is invoked and the data is passed to the cgi.
if it works I get:
request sent to server... 1... 2... 3... 4... 2006-02-17
13:28:47.491131|id:2097|name:dept|seq:0|value:53
when it fails I get:
request sent to server... 1... 2... 4...
where the 1... 2... 3... 4.... are the readyStates
Any ideas?
function rt_AJAX(req) {
document.getElementById("message").value = " request sent to
server... ";
xmlhttpPost(req);
}
function xmlhttpPost(req) {
var xmlHttpReq = false;
req.s1=true;
req.s2=true;
req.s3=true;
req.s4=true;
// IE
if (window.ActiveXObject) {
var xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
// Mozilla/Safari
else {
var xmlHttpReq = new XMLHttpRequest();
xmlHttpReq.overrideMimeType('text/xml');
}
xmlHttpReq.open('POST', req.url, true);
xmlHttpReq.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 1) { req.s1=false; }
if (xmlHttpReq.readyState == 2) { req.s2=false; }
if (xmlHttpReq.readyState == 3) { req.s3=false; }
if (xmlHttpReq.readyState == 4) { req.s4=false; }
document.getElementById("message").value += xmlHttpReq.readyState
+ "... ";
if (xmlHttpReq.readyState == 4) {
try {
req.str=xmlHttpReq.responseText;
}
catch(e) {
req.str=e;
}
updatepage(req);
if (req.s1 || req.s2 || req.s3 || req.s4) {
alert('Update Failed on the Server ("'+req.name+'")
Discontinue Use and Contact XXXXXXXXX');
}
}
}
xmlHttpReq.send(getquerystring(req));
}