专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VB Dotnet

超级郁闷JS代码 在ASP中执行OK ASP.NET失败解决方案

发布时间:2011-06-23 16:03:39 文章来源:www.iduyao.cn 采编人员:星星草
超级郁闷JS代码 在ASP中执行OK ASP.NET失败
JScript code

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" />&nbsp;读取中...';
  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 = "异常错误";
                  }
           }
     }
}





从图片中可以看出 inc目录里的Ajax.aspx文件存在 但为什么使用这段代码读取的返回结果为 404呢 很郁闷

------解决方案--------------------
当前代码在什么目录

相对目录 要相对根目录
------解决方案--------------------
你的这段JS代码在哪里?如果是在ajax.js里,然后inc文件夹下的一个页面引入了这个js文件,那么你就这样写:
JScript code

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:端口号/
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: