我写的AJAX为什么在火狐里面显示不出来?

来源:百度知道 编辑:UC知道 时间:2024/06/10 23:28:51
在IE下就可以正常显示,是不是需要加什么别的代码?function create()
{
if(window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP") ;
}
else if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
}
//''''''''''''''''''''''''''''''''''''
function loadxml(method,url,getlistt)
{
create();
xmlhttp.open(method,url,true);
xmlhttp.setRequestHeader("Content-Type","text/xml");
xmlhttp.setRequestHeader("Content-Type","GBK");
xmlhttp.onreadystatechange=function ()
{
if (xmlhttp.readystate!=4)
{
return;
}
getlistt(xmlhttp)
}
xmlhttp.send(null);
就是这段代码。。
还是不行呀,没有任何的反应

function create() {
var PubXML = false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
}

  您好!很高兴为您答疑!

加上下面这两段,如果还有问题,安装Firebug调试下,即时有问题也不会太大了,简单修改下就就行:
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlhttp = false;
  您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。