laravel get all inputs from request
$input = $request->all();
laravel get all inputs from request
$input = $request->all();
ajax laravel get values from form
<script>
var form = $('#postAddProject');
var button = $('#project-button');
var name = $('#name');
var link = $('#link');
var image = $('#image');
var token = $('input[name=_token]');
var message = $('#message');
var name_error = $('#name-error');
var link_error = $('#link-error');
var image_error = $('#image-error');
button.click(function (event){
event.preventDefault();
var formData = new FormData();
formData.append('name', name.val());
formData.append('link', link.val());
formData.append('image', image[0].files[0]);
$.ajax({
url: form.attr('action'),
method: 'post',
dataType: 'json',
contentType: false,
processData: false,
headers: {
'X-CSRF-TOKEN': token.val()
},
data: formData,
error: function (data) {
if (data.status === 422) {
name_error.html(data.responseJSON.name);
link_error.html(data.responseJSON.link);
image_error.html(data.responseJSON.image);
} else {
alert('success');
}
}
</script>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us