JSFiddle - React, Tailwind, and code Playground

by Mahadevan Sivasubramanian

HTML

<form name="registerform" id="registerform" type="post">
    <input type="text" name="check" id="check"/>
    <button onClick=regValidate();>submit</button>
</form>

JavaScript

$("#registerform").submit(function(event) {
			      /* stop form from submitting normally */
					regValidate();
					alert("hi");			    
  					event.preventDefault();
			      /* get some values from elements on the page: */
			      var $form = $( this );
			       var actionurl = $form.attr('action');

				 $.ajax({
					type:'POST', 
					url: actionurl, 
					data:$('#registerform').serialize(), 
					success: function(response) { 
					           	 alert(response);
								},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
			             		var errormsg = XMLHttpRequest.status + " - " + XMLHttpRequest.statusText;
								alert(errormsg);
								 },
			  		dataType: "text",
			  		async:false
			      });