0

这是我的代码:

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

为什么最后一行会导致 500 Internal Server Error?代码有什么问题还是我需要先记录任何内容才能看到?

4

2 回答 2

2

最后一行没有错。“500 内部服务器错误”只是服务器作为请求结果发回的结果。

这意味着“/Handlers/newAccount_handler.php”是真正的问题。如果您在浏览器中打开此 URL,则会显示错误。

于 2013-10-09T09:07:18.817 回答
1

这似乎有点旧,但我有类似的问题。值得检查您发送的 '#form-step1' 的值。在我的情况下,如果值包含引号,它会引发错误,但使用简单的文本它可以正常工作。

于 2013-11-21T00:04:24.517 回答