This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-24 23:20:14

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

AJAX Problem

So, I am working on...something secret, and I'm using AJAX to access a news feed. This is the code:

Code:

window.onload = function () {
    var newsFeed = "The news feed could not be accessed!";
    var fin = new XMLHttpRequest;
    fin.open("GET", "http://cloudscape.site50.net/feed.xml", true);
    fin.send();
    fin.onreadystatechange = function () {
        if (fin.readyState == 4 && fin.status == 200) {
            var reqIn = fin.responseXML;
            var artDate = reqIn.getElementsByTagName("date")[0];
            var artTitle = reqIn.getElementsByTagName("heading")[0];
            var artCont = reqIn.getElementsByTagName("content")[0];
            newsFeed = artDate + "\r\n" + artTitle + "\r\n\r\n" + artCont;
        }
    }
}

However, when I have an alert display the newsFeed variable, all that it says is

Code:

[object]

What am I doing wrong???? The script returns no errors, so I am completely clueless.  hmm


Fork Clamor on GitHub!

Offline

 

#2 2011-09-25 00:46:52

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: AJAX Problem

Okay, I've got it kinda figured out, however, now the problem is that I can't retrieve the data!


Fork Clamor on GitHub!

Offline

 

Board footer