-1

Though I am using {{ csrf_field() }} in my html file still got POST http://localhost:8000/add_user 500 (Internal Server Error)

here is my code

$.ajax({

    url:"/add_user",                       
    type: 'post',
    data: {_token : token, user_type_id : user_type_id,  full_name : full_name,  email : email, password : password,  username : username, date : date},
                        success:function(msg){

    $("#report").load(location.href + " #report");

   }
});
Arafat
  • 143
  • 1
  • 4
  • 14
  • Possible duplicate of [Laravel 5: Ajax Post 500 (Internal Server Error)](https://stackoverflow.com/questions/32256969/laravel-5-ajax-post-500-internal-server-error) – fab Jan 10 '18 at 10:52
  • Where do you get your token from? When using ajax (and not AXIOS) you need to include something like `var csrf_token = $('meta[name="csrf-token"]').attr('content');` in your javascript – brombeer Jan 10 '18 at 10:56
  • @kerbholz...i have added `{{ csrf_field() }}` into my form – Arafat Jan 10 '18 at 11:01
  • Your form doesn't get submitted when using ajax – brombeer Jan 10 '18 at 11:05
  • @ kerbholz....I have done the delete and update part using same type of ajax function. But in add part this error shown... It doesn't submitted I got that brother. But where is the error that I want to know :( – Arafat Jan 10 '18 at 11:08

2 Answers2

0

you can do this with csrf token

$.ajax({
  type: "POST",
  url: "url/update",
  dataType: 'json',
  data: 'id=' + id+ '&_token={{csrf_token()}}',
sancoLgates
  • 188
  • 12
0

provide your server router, its seems like you`ve missed this route request on your server

Simon Pasku
  • 539
  • 2
  • 4
  • 17