how to send post ajax request in laravel

Solutions on MaxInterview for how to send post ajax request in laravel by the best coders in the world

showing results for - "how to send post ajax request in laravel"
Linus
13 Jul 2018
1<script>
2
3  $(".save-data").click(function(event){
4      event.preventDefault();
5
6      let name = $("input[name=name]").val();
7      let email = $("input[name=email]").val();
8      let mobile_number = $("input[name=mobile_number]").val();
9      let message = $("input[name=message]").val();
10      let _token   = $('meta[name="csrf-token"]').attr('content');
11
12      $.ajax({
13        url: "/ajax-request",
14        type:"POST",
15        data:{
16          name:name,
17          email:email,
18          mobile_number:mobile_number,
19          message:message,
20          _token: _token
21        },
22        success:function(response){
23          console.log(response);
24          if(response) {
25            $('.success').text(response.success);
26            $("#ajaxform")[0].reset();
27          }
28        },
29       });
30  });
31</script>