Ajax Post

Posted 1 month ago by jaurenigel

Hi guys,

I am trying to post data using ajax and I am only getting 500 Internal error

ajax code:

$.ajaxSetup({
        headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    $(".save-company").click(function(e){
        e.preventDefault();

        var company_name = $("input[name=company_name]").val();
        var address = $("input[name=address]").val();
        var city = $("input[name=city]").val();
        var phone = $("input[name=phone]").val();
        var email = $("input[name=email]").val();

        $.ajax({
           type:'POST',
           url:'company',
           data:{company_name:company_name, address:address, city:city, phone:phone, email:email, },
           success:function(data){
              alert(data.success);
           }
        });
  });

I also have this meta tag in my blade head section:

<meta name="csrf-token" content="{{ csrf_token() }}">

Please sign in or create an account to participate in this conversation.