Forum Moderators: open

Message Too Old, No Replies

intermitant error on page load

         

hotrod

7:15 am on Aug 7, 2007 (gmt 0)

10+ Year Member



I am using the following code in my shopping cart to return estimated delivery times for the items in the cart.
However I have an intermitant problem. Sometimes, not every time or with any consistancy instead of the cart page loading, I get a blank html page with only the xmlHttp.responseText results. Any ideas?

Here is the code:

<script type="text/javascript">
function delivery_incart(shipd) {
if (document.bs.ra_psaZip.value == '') {
document.getElementById('txtGetShipDate').innerHTML = '*Estimated delivery date</strong> will be calculated after shipping information is entered.';
} else {
var xmlHttp;
xmlHttp = null;
try { // Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e) { // Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) { //Ajax is not supported. Estimated Delivery Date not shown.
return false;
}
}
}
lzip = document.bs.zipcode.value;
if (document.bs.shippings[1].checked) {
url = '<?php echo $secure_url.'usps_standard.php?Date=';?>'+shipd+'&zipcode='+lzip;
}
if (document.bs.shippings[2].checked) {
url = '<?php echo $secure_url.'usps_priority.php?Date=';?>'+shipd+'&zipcode='+lzip;
}
if (document.bs.shippings[3].checked) {
url = '<?php echo $secure_url.'usps_express.php?Date=';?>'+shipd+'&zipcode='+lzip;
}
xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState==4) {
document.write(xmlHttp.responseText+'.');
}
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
}
</SCRIPT>

mehh

9:09 pm on Aug 8, 2007 (gmt 0)

10+ Year Member




if(xmlHttp.readyState==4) {
document.write(xmlHttp.responseText+'.');
}

Theres your problem. If the page has loaded document.write simply writes over everything leaving only the string that was sent to it.