HighDots Forums  

Error undefined occured

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss Error undefined occured in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Oreste
 
Posts: n/a

Default Error undefined occured - 02-05-2008 , 02:25 PM






Finalmente mi sono deciso ad usare in modo sistematico XLMHttpRequest
con grande soddisfazione.

Tutto funziona a meraviglia ma salta fuori il messaggio "Error
undefined occured" ogni volta che chiamo la routine che mi permette di
inserire una pagina in un div. La pagina viene caricata correttamente,
non ci sono errori da validator.

La routine che uso é la seguente:

function carica_div(url,id) {
var xhr_object = null;
var position = id;
if(window.XMLHttpRequest) {
xhr_object = new XMLHttpRequest();
if (xhr_object.overrideMimeType) {xhr_object.overrideMimeType('text/
xml');}
if (typeof netscape != 'undefined' && typeof netscape.security !=
'undefined') {
try
{ netscape.security.PrivilegeManager.enablePrivilege ('UniversalBrowserRead')}
catch (e) { alert('Error ' + e.message + ' occurred.') }
}
} else if (window.ActiveXObject) { // IE
try {xhr_object = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e) {
try {xhr_object = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e) {}
}
}
if (!xhr_object) {alert('Problema XMLHTTP contactar o
administrador');return false;}
xhr_object.open("GET", url, true);
xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{
document.getElementById(position).innerHTML = xhr_object.responseText;
}
}
xhr_object.send(null);
}


Reply With Quote
  #2  
Old   
ZER0
 
Posts: n/a

Default Re: Error undefined occured - 02-06-2008 , 04:38 AM






On Tue, 5 Feb 2008 11:25:10 -0800 (PST), Oreste wrote:

Quote:
Tutto funziona a meraviglia ma salta fuori il messaggio "Error
undefined occured" ogni volta che chiamo la routine che mi permette di
inserire una pagina in un div.
Spero che tu non inserisca *effettivamente* una pagina HTML intera, in
un div.

Quote:
La routine che uso é la seguente:
[cut]

Ci sono funzioni migliori per creare oggetti XmlHttpRequest, se questo
NG ne sono state pubblicate alcune.

Quote:
try
{ netscape.security.PrivilegeManager.enablePrivilege ('UniversalBrowserRead') }
catch (e) { alert('Error ' + e.message + ' occurred.') }
}
Non ne hai bisogno.
L'errore a cui ti riferisci comunque, è su Firefox (o comunque browser
Gecko based) giusto?
Il punto è che in questo caso "e" è una stringa. Per questo motivo hai
"undefined", perché la proprietà "message" per le stringhe non esiste.

In ogni caso, l'errore effettivo è probabilmente il seguente:

A script from "..." was denied UniversalBrowserRead privileges.

P.S.
Stai attento al Cross Site Scripting.

--
~ "Ho avuto la fortuna di unire mestiere e passione,
che secondo Stendhal equivale alla felicità."
(Roland Barthes)



Reply With Quote
  #3  
Old   
Oreste
 
Posts: n/a

Default Re: Error undefined occured - 02-06-2008 , 04:56 AM



On Feb 6, 10:38 am, ZER0 <zer0.sh... (AT) libero (DOT) it> wrote:
Quote:
try
{ netscape.security.PrivilegeManager.enablePrivilege ('UniversalBrowserRead') }
catch (e) { alert('Error ' + e.message + ' occurred.') }
}
Ti ringrazio il problema era proprio lì, ho usato questo metodo per
effettuare un esperimento che mi permetteva di caricare pagine esterne
nel div, con pagine interne non è più necessario.

Ciao

Oreste


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.