A HTTP request is sent from a client to a server.
You can send data back to the client from the server in two ways: headers and the response body. It works exactly the same for both POST and GET, with the difference that you can also send a request body with POST.
Now let us assume you are using AngularJS's $http.
$http.get(url)
sends a GET request to the server. You capture the response using .success(callback)
where callback is called with a parameter representing the response body.
$http.post(url, requestData)
does exactly the same with requestData
being the request body sent.
Where
function callback(responseBody) {
}
Server-side, in PHP, everything that your script outputs is sent back to the client
and the responseBody
parameter will contain it.
So, with POST, you use the request body to send data from client to server and the response body to send data from the server back to the client.
This whole "two step" process is a HTTP POST request.