JSFiddle - React, Tailwind, and code Playground
HTML
<div id="page">
<form id="theForm" action="search.php" method="post">
<input name="first" type="text" />First name<br/>
<input name="last" type="text" />Last name<br/>
<input id="button" type="submit" />
</form>
</div>
JavaScript
$('#theForm').submit(function() {
// Add the searching icon
$("#theForm").html('Searching...<br/><img src="http://i.imgur.com/ZK0sq.gif" />');
// Make the search request to the PHP page.
$.post("/ajax_html_echo/", $(this).serialize(), function(result){
$("#page").html("The search result would be here");
});
// Cancel the regular submission of the form.
return false;
});