I have a function that I want called on submission of my Laravel Form for Ajax purposes. How can I go about this where the page does not submit and reload?
This works: (but the Enter btn does not execute)
<?php echo Form::open(); ?>
<?php echo Form::button('Search', array('id'=>'searchbtn', 'class'=>'button radius right', 'onclick'=>'myFunction(this.form)')); ?>
<?php echo Form::close(); ?>
This does not:
<?php echo Form::open(array('onsubmit' => 'myFunction(this)')); ?>
<?php echo Form::submit('Search', null, array('id'=>'searchbtn', 'class'=>'button radius right')); ?>
<?php echo Form::close(); ?>
<?php echo Form::open(array(null, null, 'onsubmit' => 'myFunction(this); return false;')); ?>
<?php echo Form::submit('Search', null, array('id'=>'searchbtn', 'class'=>'button radius right')); ?>
<?php echo Form::close(); ?>
Yayy. Now I could use my Enter button!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With