带有ajax的服务器上的错误500(发送方法)

时间:2018-09-19 13:00:44

标签: javascript ajax xmlhttprequest

我使用Javascript和AJAX发送一些信息。下面的代码在我的本地计算机上有效,但在我的服务器上无效。

var str = "/Nouvelle_Fiche" + "/" + id_fiche + "/" + id_process + "/" + type_process + "/" + id_impact + "/" + id_auteur + "/" + id_situation + "/" + questionnaires;

xmlhttp.open("POST", str, true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send();

我在行“ xmlhttp.send();”处出现错误500“内部服务器错误”。你能帮我吗 ?谢谢!

2 个答案:

答案 0 :(得分:0)

如果可以的话,尝试将data作为json发送,或在null函数中发送ajax.send。 尝试更改内容类型。

var ajax = new XMLHttpRequest();
ajax.open("GET", url, true);
ajax.setRequestHeader("Content-type", "application/json");
ajax.send( data );

ajax.onreadystatechange = function() {
  if (ajax.readyState == 4 && ajax.status == 200) {
    console.log(ajax.response);
  }
};

答案 1 :(得分:0)

现在我有一个新错误,这是“ 404未找到”,因为它添加到了我的链接“ mycustompage.htm?aspxerrorpath =“,所以现在我有了:
“ mycustompage.htm?aspxerrorpath = / Nouvelle_Fiche / 17/13766 / I / 43/1162/1/2 _”

现在有人为什么将它添加到我的链接中?谢谢