|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: May 2005
Messaggi: 340
|
[Javascript] Classi
Ho un problema con una classe JS che non riesco a far funzionare...
Codice:
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) {
}
}
}
Codice:
var a = new HtmlRequest("index.php");
a.InviaRichiesta();
Codice:
this.objHTTP has no properties http://www.xxxxxxxxx/test.php Line 33 Ultima modifica di max246 : 08-05-2007 alle 08:35. |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Sep 2001
Città: Pesaro
Messaggi: 921
|
in CreaOggettoHTTP
function CreaOggettoHTTP() { if (navigator.appName == "Microsoft Internet Explorer") { var objHttp = new ActiveXObject("Microsoft.XMLHTTP"); ie = true; } else { var objHttp = new XMLHttpRequest(); } return objHttp; } fai la dichiarazione di objHttp dentro all'if, fuori, nel return non so se l'oggetto dichiarato dentro è ancora attivo. insomma, io la farei così: function CreaOggettoHTTP() { var objHttp=0; if (navigator.appName == "Microsoft Internet Explorer") { objHttp = new ActiveXObject("Microsoft.XMLHTTP"); ie = true; } else { objHttp = new XMLHttpRequest(); } return objHttp; }
__________________
"Vedi, molte delle verità che affermiamo, dipendono dal nostro punto di vista" "Se coloro che vi guidano vi dicono: «Ecco! Il Regno è nel cielo», allora gli uccelli del cielo vi saranno prima di voi. Se essi vi dicono: «Il Regno è nel mare», allora i pesci vi saranno prima di voi. Ma il Regno è dentro di voi ed è fuori di voi" |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 04:25.



















