JSFiddle - React, Tailwind, and code Playground

by mrigess

HTML

<form name='form1' class='' method="POST">
    <p>
        <input type="text" name="a" />
    </p>
    <p>
        <input type="text" name="a" />
    </p>
    <p>
        <textarea></textarea>
    </p>
</form>

<!--form name='form2' class='allow-enter' method="POST">
    <input type="text" name="a" /> <br>
    <textarea></textarea>
</form-->

<a href="javascript:void(0)" class="sendauto">send FORM functionality</a> <br>
<a href="javascript:void(0)" class="sender">send as we do! (XML)</a><br>
<a href="javascript:void(0)" class="senderajax">send as we do! (AJAX)</a>
<p>
    Responce AJAX:
    <div id="resp-dv"></div>
</p>

JavaScript

$('form:not(".allow-enter")').submit(function() {
    alert('not-allowed-regularly');
  return false;
});

$('.sendauto').click(function(){
    //regular subissions emulate
    $('form').trigger('submit');
});

$('.sender').click(function(){
    //like XML emulate
    document.form1.submit();
});

$('.senderajax').click(function(){
    //like dialog info based submit
    $.ajax({
        url:'/echo/html/',
        type:'post',
        dataType:'html',
        data:{ html: "processed", delay: 1 },
        success:function(responseD){
            $('#resp-dv').html(responseD);
        }                                  
    });
});