阿贾克斯 - 500内部服务器错误 [英] Ajax - 500 Internal Server Error

查看:133
本文介绍了阿贾克斯 - 500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我努力学习AJAX为这个项目工作。我有一个网站,加载药物一个病人正在服用的。

I am trying to learn AJAX for this project at work. I have a site that loads medications that a patient is taking.

我把这称为AJAX功能了递归,使其包含追加单次服药7天内的历史新表。我有得到code在FF和IE浏览器来执行的问题。工作完全正常的铬。我有警报显示xmlhttp.status,这是我得到了什么......

I call this AJAX function up recursively so that it will append a new table containing a single medication and 7 days worth of history. I am having issues getting the code to execute in FF and IE. Works perfectly fine in chrome. I had alerts displaying the xmlhttp.status and this is what i got...

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

xmlhttp.status==500 (internal server error).

我评论了我所有的递归因此被缩小到了code此TID位。 (X保持吃药的数量赛道,所以我知道什么时候停止)

I commented out all of my recursion so it is narrowed down to this tid bit of code. ( x keeps track of the number of meds so i know when to stop)

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_;

              }

          }
          catch(e)
          {
              alert("Error");  
          }
      }
      xmlhttp.open("GET","URL with variables passed",true);
      xmlhttp.send();     
      document.getElementById("x").value = x + 1;
  } 

如果需要更多的code只是让我知道

if more code is needed just let me know

照片不能被即时通讯提供一个小白=(

Picture cant be provided im a noob =(

再次感谢所有谁可以帮助这个问题已经坚持了我几天吧。

Thanks again to all who can help this problem has been stuck with me for a couple of days now.

推荐答案

500(内部服务器错误)表示发生了错误的服务器端。这可能是几件事情,但我会通过验证URL和参数是否正确启动。同时,确保无论处理该请求期待的请求作为GET而不是POST。

The 500 (internal server error) means something went wrong on the server's side. It could be several things, but I would start by verifying that the URL and parameters are correct. Also, make sure that whatever handles the request is expecting the request as a GET and not a POST.

要详细了解正在发生的事情的一个有用的方法是使用如提琴手的一个工具,这将让你看所有的HTTP请求和响应,所以你可以看到你送什么,并且服务器正在响应。

One useful way to learn more about what's going on is to use a tool like Fiddler which will let you watch all HTTP requests and responses so you can see exactly what you're sending and the server is responding with.

如果您还没有一个令人信服的理由来编写自己的Ajax code,你会好得多使用处理Ajax交互为你的库。 jQuery的是一个选项。

If you don't have a compelling reason to write your own Ajax code, you would be far better off using a library that handles the Ajax interactions for you. jQuery is one option.

这篇关于阿贾克斯 - 500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆