M
Martin
Hello all!
I have the following class which define a property called
OnRSSRequestCompleted. The property is an Anonymous Function and will
be called one XmlHttpRequest will have read the file that it has to
read... When I call the method ParseRSS(url), the file is downloaded,
parsed, but the function defined in OnRSSRequestCompleted is never
called (in that case, I expect an Message Box - alert)! I really don't
understand what is going on... Could someone please help me to figure
out?
Thank you!
function RSSReader() {
var xmlHttpRequest;
this.Channel = null;
this.OnRSSRequestCompleted = function() { };
this.sendRequest = function(url) {
if (xmlHttpRequest == null) {
xmlHttpRequest = this.createXMLHttpRequest();
}
xmlHttpRequest.open("GET", url, true);
xmlHttpRequest.setRequestHeader("cache-control", "no-cache");
xmlHttpRequest.setRequestHeader("pragma", "no-cache");
xmlHttpRequest.onreadystatechange = function() {
if (xmlHttpRequest != null &&
xmlHttpRequest.readyState == 4 &&
xmlHttpRequest.status == 200 &&
xmlHttpRequest.responseText != null) {
this.Channel = new Channel();
this.Channel.ReadRSS(xmlHttpRequest.responseText);
if (this.OnRSSRequestCompleted != null) {
this.OnRSSRequestCompleted();
}
}
}
xmlHttpRequest.send(null);
} ;
this.Read = function(url) {
this.sendRequest(url);
} ;
}
function parseRSS(rssUrl) {
var rssReader = new RSSReader();
rssReader.OnRSSRequestCompleted = function() {
alert("Salut le monde!");
};
rssReader.Read(getSearchUrl());
}
I have the following class which define a property called
OnRSSRequestCompleted. The property is an Anonymous Function and will
be called one XmlHttpRequest will have read the file that it has to
read... When I call the method ParseRSS(url), the file is downloaded,
parsed, but the function defined in OnRSSRequestCompleted is never
called (in that case, I expect an Message Box - alert)! I really don't
understand what is going on... Could someone please help me to figure
out?
Thank you!
function RSSReader() {
var xmlHttpRequest;
this.Channel = null;
this.OnRSSRequestCompleted = function() { };
this.sendRequest = function(url) {
if (xmlHttpRequest == null) {
xmlHttpRequest = this.createXMLHttpRequest();
}
xmlHttpRequest.open("GET", url, true);
xmlHttpRequest.setRequestHeader("cache-control", "no-cache");
xmlHttpRequest.setRequestHeader("pragma", "no-cache");
xmlHttpRequest.onreadystatechange = function() {
if (xmlHttpRequest != null &&
xmlHttpRequest.readyState == 4 &&
xmlHttpRequest.status == 200 &&
xmlHttpRequest.responseText != null) {
this.Channel = new Channel();
this.Channel.ReadRSS(xmlHttpRequest.responseText);
if (this.OnRSSRequestCompleted != null) {
this.OnRSSRequestCompleted();
}
}
}
xmlHttpRequest.send(null);
} ;
this.Read = function(url) {
this.sendRequest(url);
} ;
}
function parseRSS(rssUrl) {
var rssReader = new RSSReader();
rssReader.OnRSSRequestCompleted = function() {
alert("Salut le monde!");
};
rssReader.Read(getSearchUrl());
}