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.
If you want to see the error in action, please use this URL


You will have to select an item to buy(don't worry about buying something just don't finish the transaction) and go to the shopping cart on that page the area in question is the zip code and sales tax fields as described here.

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

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){
	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");

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

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

//	value=data + parseFloat(subtotal);

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

	if (httpObject5 != null) {
		httpObject5.open("GET", "istaxable.php?taxabletotal="+value+"&inputText="+zipdata, true);
		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
PHP Code:

$query1="SELECT distinct STATE_A from us2 WHERE STATE_Z='".$zip."'";
$result mysql_query($query1)
    or die(
$row mysql_fetch_array($resultMYSQL_BOTH);
$row['STATE_A']=="CA") {
else {
mysql_num_rows($result)==0) {
    else {

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