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:d ept|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.getEle mentById("messa ge").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.ActiveX Object) {
var xmlHttpReq = new ActiveXObject(" Microsoft.XMLHT TP");
}
// Mozilla/Safari
else {
var xmlHttpReq = new XMLHttpRequest( );
xmlHttpReq.over rideMimeType('t ext/xml');
}
xmlHttpReq.open ('POST', req.url, true);
xmlHttpReq.setR equestHeader('C ontent-Type',
'application/x-www-form-urlencoded');
xmlHttpReq.onre adystatechange = function() {
if (xmlHttpReq.rea dyState == 1) { req.s1=false; }
if (xmlHttpReq.rea dyState == 2) { req.s2=false; }
if (xmlHttpReq.rea dyState == 3) { req.s3=false; }
if (xmlHttpReq.rea dyState == 4) { req.s4=false; }
document.getEle mentById("messa ge").value += xmlHttpReq.read yState
+ "... ";
if (xmlHttpReq.rea dyState == 4) {
try {
req.str=xmlHttp Req.responseTex t;
}
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));
}
*** Sent via Developersdex http://www.developersdex.com ***