View Full Version : XMLHttpRequest problem

02-10-2007, 10:32 PM
I've been using XMLHttpRequest for a while, like many others, but for some reason this bit of code stops just after
http = sendUsingGET(...

// XMLHttpRequest functions
function createRequest() {
var req;
var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer") {
req = new ActiveXObject("Microsoft.XMLHTTP");
} else {
req = new XMLHttpRequest();
return req;

function sendUsingGET(target, args) {
var http = createRequest();
var st = target + '?' + args;
http.open('GET', st, true);
http.onreadystatechange = function () {
if (http.readyState == 4) {
return http.responseText;
// Loads new stickies and shows them with XMLHttpRequests
// you *MUST* load ajax.js before this script is run
function getNewElems(since, frameDiv) {
//'since' is the value of a hidden field which will get updated at the end of this transaction
//since should be a UNIX style timestamp, set when the page is loaded
var when = 'time=' + since.value;
http = sendUsingGET('', when);
returnedElems = http.split("<!>");
frameDiv.innerHTML = frameDiv.innerHTML+returnedElems[0];
timestamp = new Date();
since.value = timestamp.getTime();

Basically, get.php returns a bunch of HTML, followed by the final line, which starts with <!> and then lists a bunch of properties I need to pump back into JavaScript. I think this script fails at sendUsingGET because alert(http) doesn't get called. Any ideas?