37222

500 Internal Server Error on XHR Request

Question:

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?

Answer1:

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.

Answer2:

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.

Recommend

  • Why jpa and hibernate both have “Entity” and “Table” annotations?
  • XGBOOST - DMATRIX
  • Getting EOFError along with exceptions when using ftplib
  • Criterion causing memory consumption to explode, no CAFs in sight
  • aapt.exe'' finished with non-zero exit value 1
  • MYSQ & MVC3 SQL connection error \\ ProviderManifestToken but I am using MySQL
  • How to calculate the camera position from Vuforia GL matrix?
  • Default parameter as generic type
  • Android app gives error “BatteryStatsImpl: reading network stats”
  • TextToSpeech.setEngineByPackageName() triggers NullPointerException
  • custom UITableViewCell with image for highlighting
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Moving mysql files across servers
  • Meteor: Do Something On Email Verification Confirmation
  • SignalR .NET Client Invoke throws an exception
  • Using variable in a value field in jMeter
  • Using $this when not in object context
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • Resize panoramic image to fixed size
  • Volusion's generic SQL folder, functionality
  • Updating server-side rendering client-side
  • How to check if every primary key value is being referenced as foreign key in another table
  • Perl system calls when running as another user using sudo
  • Where to put my custom functions in Wordpress?
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • How to pass list parameters for each object using Spring MVC?
  • RestKit - RKRequestDelegate does not exist
  • Comma separated Values
  • A cron job substitute?
  • json Serialization in asp
  • WPF Applying a trigger on binding failure
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?