is there any implementation of AJAX Post in Pure Javascript (maybe using xmlhttprequest)?
For example if I have a form like this:
<form action=request.php id=register_form>
<input type=text name=first_name placeholder=First Name>
<input type=text name=last_name placeholder=LastName>
<input type=submit value=submit_now>
</form>
and this is my implementation of the AJAX in jQuery
$('#register_form').submit(function(e) {
var postData = $(this).serializeArray();
var formURL = $(this).attr(action);
/* start ajax submission process */
$.ajax({
url: formURL,
type: POST,
data: postData,
success: function(data, textStatus, jqXHR) {
alert('Success!');
},
error: function(jqXHR, textStatus, errorThrown) {
alert('Error occurred!');
}
});
e.preventDefault(); //STOP default action
/* ends ajax submission process */
});
Can I do the same WITHOUT the use of jQuery? If it is possible, how can I implement the above jQuery code into pure/plain Javascript code?