InterviewSolution
| 1. |
How to use Ajax in any form submission? |
|
Answer» EXAMPLE
<script type="text/javascript"> $(DOCUMENT).ready(function() { $("FORMIDORCLASS").submit(function(e){ // FORMIDORCLASS will your your form CLASS OT ID e.preventDefault(); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') // you have to PASS in between tag } }) var formData = $("FORMIDORCLASS").serialize(); $.ajax({ type: "POST", url: "", data : formData, success: function( response ) { // Write here your sucees message }, error: function(response) { // Write here your error message }, }); return false; }); }); </script> |
|