简体   繁体   中英

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? 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.

This means that '/Handlers/newAccount_handler.php' is the real problem. If you open this URL in a browser it will show you an error.

This seems a bit old, but I've had similar issue. It's worth checking what the value of '#form-step1' you are sending. In my case if the value contained quotes it would throw an error, but with simple text it worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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