简体   繁体   English

XHR请求上的500内部服务器错误

[英]500 Internal Server Error on XHR Request

Here is my code: 这是我的代码:

var fd = new FormData(document.querySelector('#form-step1'));
var xhr = new XMLHttpRequest();

xhr.open('POST', '/Handlers/newAccount_handler.php', true);

xhr.send(fd); // this line is causing a 500 Internal Server Error and the data is not saved to the MySQL table

Why is the last line causing a 500 Internal Server Error? 为什么最后一行会导致500 Internal Server Error? Is there anything wrong with the code or do I need to log anything first to see? 代码有什么问题吗?还是需要先登录才能查看?

There is nothing wrong with the last line. 最后一行没有错。 The '500 Internal Server Error' is simply the result the server sends back as the result of the request. “ 500 Internal Server Error”仅是服务器作为请求结果发回的结果。

This means that '/Handlers/newAccount_handler.php' is the real problem. 这意味着“ /Handlers/newAccount_handler.php”是真正的问题。 If you open this URL in a browser it will show you an error. 如果您在浏览器中打开此URL,它将显示一个错误。

This seems a bit old, but I've had similar issue. 这似乎有些陈旧,但我也遇到过类似的问题。 It's worth checking what the value of '#form-step1' you are sending. 值得检查您要发送的“#form-step1”的值。 In my case if the value contained quotes it would throw an error, but with simple text it worked fine. 在我的情况下,如果值包含引号,则将引发错误,但使用简单的文本则可以正常工作。

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

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