Hi,
I am having a problem with an AJAX request.
The URL in a browser works fine – that is, it returns data.
But when I use the same URL in an AJAX request, the data is not returned, but the ready state is 4.
Any ideas? I thought it might have something to do with a “chunked” response.
See code below.
[code=html]
<html>
<head>
<script type=”text/javascript” charset=”utf-8″>
function sendAusPostRequest() {
var urlString = getURLString();
loadXMLDoc(urlString, ausPostResponseReceived);
}
function getURLString() {
var urlString = “http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=6025&Destination_Postcode=6055&Country=AU&Weight=100&Service_Type=STANDARD&Length=100&Width=100&Height=100&Quantity=1”;
return urlString;
}
function ausPostResponseReceived(responseText) {
window.alert(responseText);
}
function loadXMLDoc(urlString, callbackFunction) {
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
callbackFunction(xmlhttp.responseText);
}
}
xmlhttp.open(“GET”, urlString, true);
xmlhttp.send();
}
</script>
</head>
<body>
<div onclick=”sendAusPostRequest()”>
Click On Me To Send Request
</div>
</body>
</html>