PDA

View Full Version : Blogger XMLHTTPREQUEST


Endeavor88
11-12-2005, 12:14 PM
Out of fun, I recently made a blog at blogger.com. Being curious, I tried to implement a xmlhttprequest into the blog's template. The function below works perfectly until it reaches the req.open() function. I have tried this same script on my own web server and it works perfectly. Does blogger not allow xmlhttprequests??

function loadXMLDoc(url) {
req = false;
// branch for native XMLHttpRequest Object
// Safari and Mozilla
if(window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}

if(req) {
req.onreadystatechange = processReqChange;
alert('hello, '+url);
req.open("GET", url, true); // true = act asynchronously (don't wait for server response)
alert('hello, '+url);
req.send("");
}
}

RysChwith
11-14-2005, 08:22 AM
Potentially relevent warning from Apple:

The domain of the URL request destination must be the same as the one that serves up the page containing the script. This means, unfortunately, that client-side scripts cannot fetch web service data from other sources, and blend that data into a page.True, you're not using a web service, per se, but unless the page is in your Blogger directory, you're not likely to get a response.

Rys