超级郁闷JS代码 在ASP中执行OK ASP.NET失败
function getHttpObject() { var objType = false; try { objType = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { objType = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { objType = new XMLHttpRequest(); } } return objType;}function ShowIsBest(_id){ $("CD_IsBest"+_id).innerHTML= "<img src='img/star1.gif' border='0' style='cursor:pointer;margin-left:2px;' title='推荐为1星级' onclick='EditIsBest(_id,1)' /><img src='img/star1.gif' border='0' style='cursor:pointer;margin-left:2px;' title='推荐为2星级' onclick='EditIsBest(_id,2)' /><img src='img/star1.gif' border='0' style='cursor:pointer;margin-left:2px;' title='推荐为3星级' onclick='EditIsBest(_id,3)' /><img src='img/star1.gif' border='0' style='cursor:pointer;margin-left:2px;' title='推荐为4星级' onclick='EditIsBest(_id,4)' /><img src='img/star1.gif' border='0' style='cursor:pointer;margin-left:2px;' title='推荐为5星级' onclick='EditIsBest(_id,5)' />"; //$("CD_IsBest"+_id).innerHTML= '<img src="img/loading.gif" /> 读取中...'; var theHttpRequest = getHttpObject(); theHttpRequest.onreadystatechange = function () { processAJAX(); }; theHttpRequest.open("GET", "inc/Ajax.aspx?action=showisbest&id=" + _id, true); theHttpRequest.send(null); function processAJAX() { if (theHttpRequest.readyState == 4) { if (theHttpRequest.status == 200) { document.getElementById("CD_IsBest"+_id).innerHTML = unescape(theHttpRequest.responseText); } else { alert(theHttpRequest.responseText) document.getElementById("CD_IsBest"+_id).innerHTML = "异常错误"; } } }}
function ShowIsBest(_id){ $("CD_IsBest"+_id).innerHTML= "<img src='../Img/star1.gif' //...后面省略 ... theHttpRequest.open("GET", "Ajax.aspx?action=showisbest&id=" + _id, true); theHttpRequest.send(null); //...后面省略}
[解决办法]
单独访问Ajax.aspx
[解决办法]
你在vs中调试的时候,看地址栏,
在/admin/之前是http://localhost:端口号/项目名/,还是http://localhost:端口号/