<script>
$(".save-data").click(function(event){
event.preventDefault();
let name = $("input[name=name]").val();
let email = $("input[name=email]").val();
let mobile_number = $("input[name=mobile_number]").val();
let message = $("input[name=message]").val();
let _token = $('meta[name="csrf-token"]').attr('content');
$.ajax({
url: "/ajax-request",
type:"POST",
data:{
name:name,
email:email,
mobile_number:mobile_number,
message:message,
_token: _token
},
success:function(response){
console.log(response);
if(response) {
$('.success').text(response.success);
$("#ajaxform")[0].reset();
}
},
});
});
</script>