Answers for "how to send post ajax request in laravel"

0

how to send post ajax request in laravel

<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>
Posted by: Guest on August-26-2021

Code answers related to "how to send post ajax request in laravel"

Code answers related to "Javascript"

Browse Popular Code Answers by Language