高人们给看看,为什么这个例子提示xmlHttp未定义
function makeRequest(url, functionName, httpType, sendData) {
xmlHttp = false;
if (!httpType) httpType = "GET";
if (window.XMLHttpRequest) { // Non-IE...
xmlHttp = new XMLHttpRequest();
if (xmlHttp.overrideMimeType) {
xmlHttp.overrideMimeType('text/plain');
}
} else if (window.ActiveXObject) { // IE
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!xmlHttp) {
alert('Cannot send an XMLHTTP request');
return false;
}
var changefunc="xmlHttp.onreadystatechange = "+functionName;
eval (changefunc);
//xmlHttp.onreadystatechange = alertContents;
xmlHttp.open(httpType, url, true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send(sendData);
}
function getComList(classid,id,pagenum){
var url = '/e/ajax/index.php?';
var params ='action=getComList' + '&classid=' + classid + '&id=' + id + '&pagenum=' + pagenum;
url+=params;
var functionName=function (){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
if(xmlHttp.responseText!=0){
$("#commentinfo").html(xmlHttp.responseText);
}
else {
$("#commentinfo").html("");
}
}
}
};
makeRequest(url, functionName, "GET", '');
}
function getComPage(classid,id,pagenum){
var url = '/e/ajax/index.php?';
var params ='action=getComPage' + '&classid=' + classid + '&id=' + id + '&pagenum=' + pagenum;
url+=params;
var functionName=function (classid,id,pagenum){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
if(xmlHttp.responseText!=0){
$(".comnav1").html(xmlHttp.responseText);
getComList(classid,id,pagenum);
}
else {
$(".comnav1").html("");
}
}
else if(xmlHttp.readyState!=4)
{
loadING("#commentinfo");
}
}
};
makeRequest(url, functionName(classid,id,pagenum), "GET", '');
}
其实我修改了makeRequest(url, functionName(classid,id,pagenum), "GET", ''); ,以前是
makeRequest(url, functionName, "GET", '');不带参数的,现在带了参数,该了一下functionName的结构。就出现了这种错误,请问怎么会是,谢谢了