Hi I have a peculiar issue with IE and AJAX. I have a certain script that works fine the data is processed the for the first time but if it is run with the same data it fails to operate. This failure only occurs in IE.

It is part of the checkout process on our website, http://www.fuzzycross.com
The issue occurs in the checkout area where you enter the zip code in IE you will see the issue if you enter the data from the example below. You will have to select an item and add it to the cart in order to get to the area that has the issue.

Here is a typical situation where I see a failure again only in IE.
you go to the checkout process and enter a shipping option and a zipcode say 91401; it processes normally. Processing normally means calling a php script that sends a query to a mysql database to get a valid value for calculating a sales tax. In this case becauseit is a California zip code and we are in California it comes back with a value and the tax field in the form is updated.
If the zip code is not in California it returns with 0 and that is updated in the tax field. such would be the case if 55056 was entered for the zipcode and again it works just fine, the first time.

If, however, I enter 91401 it comes back and the field is updated. I then change it to 55056 the field changes to zero, again correct, I then change it to 91402 it still process correctly.

Now when I do this same process again in a different session I start with 91401, it works, I change it to 55056, it still works , I change it back to 91401 and nothing happensi change it again to say 91402 and it works this time if I change it back to 55056; nothing, 91401; nothing, 91402; nothing, but again if I enter 91403 it works and a value is returned.

Again this is only in IE

Here is my code for my AJAX calls and the PHP script that processes the database call


javascript
Code:
function getHTTPObject(){
	if (window.ActiveXObject)
		return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		return new XMLHttpRequest();
		else {
			alert("Your browser does not support AJAX.");
			return null;
		}
}


function doWork5(subtotal){
	error=0;
	if( ( (document.cartform.shipping[0].checked)  || (document.cartform.shipping[1].checked) || (document.cartform.shipping[2].checked) ) ==0) {
		alert("You need to select a shipping option");
		error=1;
		}

//	data =parseFloat(document.getElementById('shippingval').value.substr(1));
	zipdata =document.getElementById('zip').value;

	if (zipdata == '#####') {
		alert("You need to enter a Zip Code");
		error=1;
	}
	
	if(error==1) {
		return;
	}

//	value=data + parseFloat(subtotal);

	value= parseFloat(subtotal);
	httpObject5 = getHTTPObject();


	if (httpObject5 != null) {
		httpObject5.open("GET", "istaxable.php?taxabletotal="+value+"&inputText="+zipdata, true);
		httpObject5.send(null);
		httpObject5.onreadystatechange = setOutput5;
	}
}

function setOutput5(){
	if(httpObject5.readyState == 4){
		document.cartform.taxval.value="$" + parseFloat(httpObject5.responseText);
		grandtotal = parseFloat(httpObject5.responseText) + parseFloat(document.cartform.ordersubtotal.value.substr(1)) + parseFloat(document.cartform.shippingval.value.substr(1));
		document.cartform.ordertotal.value="$" + grandtotal.toFixed(2);
	}
}
php script istaxable.php
Code:
$subtotal=$_GET['taxabletotal'];
$zip=$_GET['inputText'];
$query1="SELECT distinct STATE_A from us2 WHERE STATE_Z='".$zip."'";
$result = mysql_query($query1)
	or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_BOTH);
if($row['STATE_A']=="CA") {
	$taxval=($subtotal*.0725);
	printf("%01.2f", $taxval);
}
else {
	if(mysql_num_rows($result)==0) {
		echo "";
	}
	else {
		echo"0.00";
	}
}
Subsequent calls to other functions with the same data after this call is processed are processed correctly.
No error is ever indicated that I can see.
In my testing I have added alert statements to verify the data is being sent in correctly and it is.

It appears to just decide not to process the php script some of the time

I guess I say thanks to IE for another buggy thing

Any help or assistance will be greatly appreciated

thanks
Jeff