Skip to content

Instantly share code, notes, and snippets.

@zymawy
Created February 7, 2019 17:23
Show Gist options
  • Save zymawy/fb9fc8332137e5606154b4505dd2d3ea to your computer and use it in GitHub Desktop.
Save zymawy/fb9fc8332137e5606154b4505dd2d3ea to your computer and use it in GitHub Desktop.
jQuery(document).ready(function(){
jQuery('#submit').click(function(e){
e.preventDefault();
jQuery.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
}
});
jQuery.ajax({
url: "{{ url('/form') }}",
method: 'post',
data: {
name: jQuery('#footballername').val(),
type: jQuery('#club').val(),
price: jQuery('#country').val()
},
success: function(data){
jQuery.each(data.errors, function(key, value){
jQuery('.alert-danger').show();
jQuery('.alert-danger').append('<p>'+value+'</p>');
});
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment