// JavaScript Document
function createXMLHttpRequest()
{
var xmlhttp=false;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
if (!xmlhttp&&window.ActiveXObject)
{
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.5.0")
} catch(e) {
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0")
} catch(e) {
try
{
new ActiveXObject("Msxml2.XMLHTTP")
} catch(e) {
try{new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}
}
}
}
}
if(!xmlhttp){
alert("Error");
}
return xmlhttp;} 新手刚学习ajax,感觉也没错啊,在IE浏览器下没问题,但在火狐浏览器下,不能获得数据!火狐还下了最新的版本,还是不行,都快哭了,大神救我
function createXMLHttpRequest()
{
var xmlhttp=false;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
if (!xmlhttp&&window.ActiveXObject)
{
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.5.0")
} catch(e) {
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0")
} catch(e) {
try
{
new ActiveXObject("Msxml2.XMLHTTP")
} catch(e) {
try{new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}
}
}
}
}
if(!xmlhttp){
alert("Error");
}
return xmlhttp;} 新手刚学习ajax,感觉也没错啊,在IE浏览器下没问题,但在火狐浏览器下,不能获得数据!火狐还下了最新的版本,还是不行,都快哭了,大神救我
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","/ajax/test1.txt",false);
xmlhttp.send();
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
</script>
</head>
<body><div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">通过 AJAX 改变内容</button></body>
</html>