JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<fieldset>
<label for="answer"><strong>Your Answer : </strong>
</label>
<input type="text" name="answer" id="answer" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
JavaScript
$(document).ready(function () {
$(document).on('keypress',function(e)
{
if(e.which==13 && $("#answer").val().length>0)
{
alert("hi"); // do your ajax call here
}
});
});