Hi
I hope someone can help me please. I have a problem using a value returning from an AJAX call. The AJAX is working:
[FONT="Courier New"]
var ajaxHTTP; // Global JS variable
function checkOrder() {
if (window.XMLHttpRequest) {
ajaxHTTP = new XMLHttpRequest();
} else {
ajaxHTTP = new ActiveXObject("Microsoft.XMLHTTP");
}
var params = 'order=1';
var url = 'checkstatus.php?' + params;
ajaxHTTP.open('get', url, true);
ajaxHTTP.onreadystatechange = showOrderStatus;
ajaxHTTP.send(null);
}
function showOrderStatus() {
mydiv = document.getElementById('mydiv');
var response = '';
if (ajaxHTTP.readyState == 4 || ajaxHTTP.readyState == 'complete') {
response = ajaxHTTP.responseText;
if (response == '1') {
mydiv.innerHTML = 'ordered';
}
}
}
[/FONT]
checkstatus.php
[FONT="Courier New"]<?php
$order = $_GET['order'];
echo "1";
?>[/FONT]
The problem I am having is that whilst ajaxHTTP.responseText returns the value 1 (via checkstatus.php), the IF statement doesn't work at all.
Anyone got any ideas why please?
Thanks in advance.
BB