小编Nic*_*ckF的帖子

Ajax - 500内部服务器错误

我正在努力为这个项目学习AJAX.我有一个网站,可以加载患者正在服用的药物.

我以递归方式调用这个AJAX函数,以便它附加一个包含单一药物和7天历史记录的新表.我在让代码在FF和IE中执行时遇到问题.铬合金完美无缺.我有警告显示xmlhttp.status,这就是我得到的:

xmlhttp.status == 500(内部服务器错误).

我评论了所有的递归,所以它缩小到这个代码的代码.(x跟踪药物的数量,所以我知道什么时候停止)

function LoadMeds()


  if ( x == MaxMedCount )
  {
      document.getElementById("the_day").value = parseInt(document.getElementById("the_day").value)+7; 
  }
  if ( x == (MaxMedCount - 1) )
  {
      document.getElementById("x").value = x + 1;
      show();
  }
  else
  { 

      if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
      }
      else
      {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange=function()
      {
          try 
          {      
              if (xmlhttp.readyState==4 && xmlhttp.status==200)
              {     
                  var div = document.createElement('div');
                  div.innerHTML= xmlhttp.responseText;
                  document.getElementById('MedTable').appendChild(div);
                  document.getElementById("the_med_").value = the_med_;

              }

          } …
Run Code Online (Sandbox Code Playgroud)

javascript ajax xmlhttprequest

25
推荐指数
3
解决办法
28万
查看次数

标签 统计

ajax ×1

javascript ×1

xmlhttprequest ×1