【发布时间】:2009-01-04 15:28:21
【问题描述】:
谁能解释一下原因:
function doAjax() {
var xmlHttpReq = false;
try { // Firefox, Opera 8.0+ and Safari
xmlHttpReq = new XMLHttpRequest();
}
catch (e) { // Internet Explorer
try {
xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser does not support AJAX. Please use an AJAX compatible browser.");
return false;
}
}
}
xmlHttpReq.open('GET', 'handler.php', true);
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 4) {
var response = xmlHttpReq.responseText;
handleAjaxResponse(response);
}
};
xmlHttpReq.send(null);
return true;
}
导致以下验证错误:
Error:
Implied global: ActiveXObject 8, XMLHttpRequest 4, alert 15, handleAjaxResponse 24
Problem at line 10 character 16: 'e' is already defined.
catch (e) {
Problem at line 14 character 20: 'e' is already defined.
catch (e) {
由 JSlint.com javascript 验证器提供
【问题讨论】:
标签: javascript ajax validation