Jump to content

How to send data in request body


Recommended Posts

You can just send data without any name/value pairs, any data you send will go in the request body. It will only get automatically parsed by something like PHP if it's in the name/value pair format.


var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = ajax_handler;
xhttp.open("POST", "script.php", true);
xhttp.send('request body here');
You may still want to URL-encode the request body. In PHP, for example, you would get the request body by reading from the php input stream.



  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...