XMLHttpRequest无法在Mozilla中运行 [英] XMLHttpRequest not working in Mozilla

查看:62
本文介绍了XMLHttpRequest无法在Mozilla中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





代码在Mozilla中不起作用,但似乎在Chrome中运行良好。感谢您的帮助。



Hi,

The code is not working in Mozilla but seems to be working fine in Chrome. Thank you for helping.

function addItem(str) {
	var request;
	if (window.XMLHttpRequest){//firefox etc.
		request = new XMLHttpRequest();
	}
	else if (window.ActiveXObject){//ie
		request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	request.open('GET', "checkinout-actions/add-more-items-code.php?q="+str);
 
	request.onreadystatechange = function () {
		if (request.readyState == 1) { return }
		else if (request.readyState == 4) {
			if (request.status < 400) {
				// do your stuff here
				document.getElementById("txtHint").innerHTML=request.responseText;
			}
			else if (error != null)
				error(request);
		}
	};
	request.send();
	window.location.reload();
}

推荐答案

删除行 window.location.reload()然后再试一次。



运行Mozilla调试器中的代码,看看发生了什么。
Remove the line window.location.reload() and try again.

Run the code in the Mozilla debugger and see what is happening.


一个很大的警告你: window.ActiveXObject 巨大滥用,非常不安全。如果一些要求苛刻的用户会看到您使用这些脏东西,他们可以将您的网站列入黑名单。永远不要做这些事情,只是把它刮掉。所有非废话浏览器都可以在没有它的情况下工作,而那些不能得到任何关注的浏览器都可以工作。他们太过时了。



-SA
A big warning for you: window.ActiveXObject is a huge abuse, very unsafe. If some demanding users will see that you use such dirty things, they can blacklist your site. Never do such things, just scratch it out. All non-nonsense browsers will work without it, and those which cannot does not deserve any attention; they are way too obsolete.

—SA


这篇关于XMLHttpRequest无法在Mozilla中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆