max246
08-05-2007, 08:31
Ho un problema con una classe JS che non riesco a far funzionare...
function HtmlRequest (url) {
this.objHTTP = CreaOggettoHTTP();
this.url = url;
this.method = "GET";
this.InviaRichiesta = InviaRichiesta;
this.Operazione = Operazione;
function CreaOggettoHTTP() {
if (navigator.appName == "Microsoft Internet Explorer") {
var objHttp = new ActiveXObject("Microsoft.XMLHTTP");
ie = true;
} else {
var objHttp = new XMLHttpRequest();
}
return objHttp;
}
function InviaRichiesta() {
this.objHTTP.open(this.method,this.url,true);
this.objHTTP.onreadystatechange = Operazione;
this.objHTTP.send(null);
}
function Operazione() {
//objHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//objHttp.send("search_what=All");
alert(this.objHTTP.readyState);
if (this.objHTTP.readyState == 4) {
}
}
}
var a = new HtmlRequest("index.php");
a.InviaRichiesta();
Ma mi ritorna questo errore ... aiuto!!!
this.objHTTP has no properties
http://www.xxxxxxxxx/test.php
Line 33
function HtmlRequest (url) {
this.objHTTP = CreaOggettoHTTP();
this.url = url;
this.method = "GET";
this.InviaRichiesta = InviaRichiesta;
this.Operazione = Operazione;
function CreaOggettoHTTP() {
if (navigator.appName == "Microsoft Internet Explorer") {
var objHttp = new ActiveXObject("Microsoft.XMLHTTP");
ie = true;
} else {
var objHttp = new XMLHttpRequest();
}
return objHttp;
}
function InviaRichiesta() {
this.objHTTP.open(this.method,this.url,true);
this.objHTTP.onreadystatechange = Operazione;
this.objHTTP.send(null);
}
function Operazione() {
//objHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//objHttp.send("search_what=All");
alert(this.objHTTP.readyState);
if (this.objHTTP.readyState == 4) {
}
}
}
var a = new HtmlRequest("index.php");
a.InviaRichiesta();
Ma mi ritorna questo errore ... aiuto!!!
this.objHTTP has no properties
http://www.xxxxxxxxx/test.php
Line 33