The user's status text should be submitted to the server without reloading the page. To do this we can use the AJAX approach, where the user's data can be sent to the server with the HTTP methods, and wait for the server's response. As soon as the server responds, we can parse the response data and may take our decision programmatically. In our case, if the server responded with a success result, we will update our interface DOM according to that.
Simply, we will use AJAX to submit the user's status text with the HTTP POST
method to our server-side PHP code residing at index.php
, and we will configure the expected data type from the server to be JSON. So, we can easily parse the JSON and determine whether the status was saved successfully or not. From a successful server response, we can update the status stream display list and place the newly posted status at the top of that list. However, in the case of any failure or error, we can parse...