【问题标题】:jsp ajax call throwing 500 (Internal Server Error)jsp ajax 调用抛出 500(内部服务器错误)
【发布时间】:2023-03-24 07:00:02
【问题描述】:

我正在尝试 ajax 调用更改 .jsp 中的值,如下所示:-

    $(".custodianautocomplete").change(function() {
    $('#custodianIDSelected').html($(this).val());      
    var IDSelected = $(this).val();     
    if (window.XMLHttpRequest) {        
      xRequest1 = new XMLHttpRequest();        
    } else {        
      xRequest1 = new ActiveXObject("Microsoft.XMLHTTP");        
    }        
    xRequest1.onreadystatechange = function() {        
      if ((xRequest1.readyState == 4) && (xRequest1.status == 200)) {        
        $(this).parent("td").next().find("input[name=hall_location]").val(xRequest1.responseText);        
      }        
    }        
    xRequest1.open("get", "/chbs/adm/getEmpName.jsp?q=" + IDSelected, "true");        
    xRequest1.send();        
});

网页的执行甚至没有到达getEmpName.jsp,控制台显示如下错误

updateHallNames.jsp:254 GET http://localhost:8080/chbs/adm/getEmpName.jsp?q=ISRO008 500 (Internal Server Error)
(anonymous) @ updateHallNames.jsp:254
dispatch @ jquery-3.2.1.min.js:1627
q.handle @ jquery-3.2.1.min.js:1589

updateHallNames.jsp:254 中显示的第 254 行指向 xRequest1.send();

我无法找出错误的原因。

【问题讨论】:

    标签: ajax jsp


    【解决方案1】:

    我已经解决了这个错误。问题在于getEmpName.jsp 代码中的错误。我通过使用标准的ajax 功能和.fail() 找到了错误的详细信息。修改后的代码见链接
    here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-06
      • 2023-03-20
      • 2016-03-23
      • 1970-01-01
      相关资源
      最近更新 更多