# Other Programming > AJAX >  AJAX code does not always work in IE

## jjanes

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


```
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


```

$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

----------


## JeffAgee

I know this thread is old. But just in case someone else has the same problem, it's likely an Internet Explorer cache issue.
Here's an article about it and the solution: AJAX cache problem in IE.

----------


## patel_rosh

There is an ongoing issue with IE and AJAX and its an ongoing process.. and partly 1% of people uses IE so don't bother about it and chillax!!

----------


## bestellen

When the ASP.NET AJAX Functionality is not working on a web page, it is usually due to the fact that the javascript needed for AJAX is not sent to the client from the server for some reason.

Sys is undefined. You might see this error message when there is a problem with the client in receiving the javascript sent by the server for the AJAX functionality. Some browser might not show an alert of this error message, and you might see the status bar saying done, but in yellow. Yellow always indicates that you have an error occurred while the page was getting loaded.

----------


## Claire_Anderson

Internet Explorer is called worst Nightmare for developers, because the code that would work in other browsers would stop working. Even though IE is  used by a very small group of audience but developers had to develop applications that could run across multiple platforms

----------


## RockybBalboa

IE has lots of problem with AJAX codes. I would simply avoid it.

----------

