PDA

View Full Version : [JAVASCRIPT] Uso dell'oggetto xml http request


das
04-12-2008, 18:53
Ho trovato questo esempio su internet:

[NomeFile=xmlhttp.js]

var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp=false;
}
}
@else
xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}



[NomeFile=Index.html]


<script src="xmlhttp.js" type="text/javascript">
xmlhttp=false
</script>

<script type="text/javascript">
if (xmlhttp) {
document.write('<p class="example"><a href="#" onclick="example2();return false;">Try the example 2.</a></p>')
}
function example2() {
xmlhttp.open("HEAD", "http://www.jibbering.com/faq/index.html",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
alert(xmlhttp.getAllResponseHeaders())
}
}
xmlhttp.send(null)
}


Su Internet Explorer, mi avvisa che lo script potrebbe essere insicuro ma funziona, su firefox invece niente. Quando clicco su example 2 non fa nulla.

Qualcuno sa perchè ?

Thanks

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.