简体   繁体   English

使用 ajax(发送方法)在服务器上出现错误 500

[英]Error 500 on server with ajax (send method)

I use Javascript and AJAX to send some informations.我使用 Javascript 和 AJAX 发送一些信息。 The code below works on my local machine but not on my server.下面的代码适用于我的本地机器,但不适用于我的服务器。

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();

I have an error 500 "Internal Server Error" with the line "xmlhttp.send();".我有一个错误 500“内部服务器错误”,行“xmlhttp.send();”。 Can you help me please ?你能帮我吗 ? Thank you !谢谢 !

Try to send data as json if you can or send null in ajax.send functions.如果可以,请尝试将data作为 json 发送,或者在ajax.send函数中发送null Try to change Content-type.尝试更改内容类型。

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);
  }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM