• <legend id='28huw'><style id='28huw'><dir id='28huw'><q id='28huw'></q></dir></style></legend>
    <i id='28huw'><tr id='28huw'><dt id='28huw'><q id='28huw'><span id='28huw'><b id='28huw'><form id='28huw'><ins id='28huw'></ins><ul id='28huw'></ul><sub id='28huw'></sub></form><legend id='28huw'></legend><bdo id='28huw'><pre id='28huw'><center id='28huw'></center></pre></bdo></b><th id='28huw'></th></span></q></dt></tr></i><div id='28huw'><tfoot id='28huw'></tfoot><dl id='28huw'><fieldset id='28huw'></fieldset></dl></div>

    <small id='28huw'></small><noframes id='28huw'>

    <tfoot id='28huw'></tfoot>

        • <bdo id='28huw'></bdo><ul id='28huw'></ul>

        Ajax - 500 内部服务器错误

        时间:2023-10-14

              <tbody id='ccx37'></tbody>

            <small id='ccx37'></small><noframes id='ccx37'>

          • <tfoot id='ccx37'></tfoot>

                <bdo id='ccx37'></bdo><ul id='ccx37'></ul>
                <legend id='ccx37'><style id='ccx37'><dir id='ccx37'><q id='ccx37'></q></dir></style></legend>

                  <i id='ccx37'><tr id='ccx37'><dt id='ccx37'><q id='ccx37'><span id='ccx37'><b id='ccx37'><form id='ccx37'><ins id='ccx37'></ins><ul id='ccx37'></ul><sub id='ccx37'></sub></form><legend id='ccx37'></legend><bdo id='ccx37'><pre id='ccx37'><center id='ccx37'></center></pre></bdo></b><th id='ccx37'></th></span></q></dt></tr></i><div id='ccx37'><tfoot id='ccx37'></tfoot><dl id='ccx37'><fieldset id='ccx37'></fieldset></dl></div>
                1. 本文介绍了Ajax - 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 天的历史记录.我在让代码在 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).

                  我注释掉了我所有的递归,所以它被缩小到这个小代码.(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;
                    } 
                  

                  如果需要更多代码,请告诉我.

                  if more code is needed just let me know.

                  推荐答案

                  500 (internal server error) 表示服务器端出现问题.这可能是几件事,但我会首先验证 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.

                  了解更多信息的一种有用方法是使用 Fiddler 之类的工具让您查看所有 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 代码,那么最好使用一个为您处理 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.

                  这篇关于Ajax - 500 内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 XMLHTTPRequest 进行基本身份验证 下一篇:responseXML 始终为空

                  相关文章

                  最新文章

                  <small id='G2Ld9'></small><noframes id='G2Ld9'>

                2. <i id='G2Ld9'><tr id='G2Ld9'><dt id='G2Ld9'><q id='G2Ld9'><span id='G2Ld9'><b id='G2Ld9'><form id='G2Ld9'><ins id='G2Ld9'></ins><ul id='G2Ld9'></ul><sub id='G2Ld9'></sub></form><legend id='G2Ld9'></legend><bdo id='G2Ld9'><pre id='G2Ld9'><center id='G2Ld9'></center></pre></bdo></b><th id='G2Ld9'></th></span></q></dt></tr></i><div id='G2Ld9'><tfoot id='G2Ld9'></tfoot><dl id='G2Ld9'><fieldset id='G2Ld9'></fieldset></dl></div>
                3. <tfoot id='G2Ld9'></tfoot>
                  <legend id='G2Ld9'><style id='G2Ld9'><dir id='G2Ld9'><q id='G2Ld9'></q></dir></style></legend>

                    • <bdo id='G2Ld9'></bdo><ul id='G2Ld9'></ul>