javascript - Keep getting null when sending an array of data using AJAX to Laravel Controller -


i trying send array of data client-side using ajax backend laravel controller. problem keep getting null when data-dump in controller.

i have tried many possible solutions online , nothing working me. need know have gone wrong or missed. in advance.

this route

route::post('/event/going/{id}', ['as' => $s . 'going-post', 'uses' => 'pagescontroller@goingforevent']); 

this controller

public function goingforevent(request $request, $id) {             dd(input::get('result')); }    

this html code

<a data-url="{{route('public.going-post', $singleevent->id)}}" id="imgoing" class="ui attached positive button">i'm going</a>                     <div class="or"></div> 

this ajax code

<script>     $.ajaxsetup({         headers: {             'x-csrf-token': $('meta[name="csrf-token"]').attr('content')         }     });      $("#imgoing").click(function() {          var url = $(this).data('url');         console.log(url);          //var x = url.substr(url.lastindexof('/') + 1);        // console.log("/event/going/" + x);          swal({           title: 'multiple inputs',           html:             '<input type="text" id="firstname" class="swal2-input">' +             '<input type="text" id="lastname" class="swal2-input">' +             '<input type="email" id="email" class="swal2-input">',           preconfirm: function () {             return new promise(function (resolve) {               resolve([                 $('#firstname').val(),                 $('#lastname').val(),                 $('#email').val(),               ])             })           },           onopen: function () {             $('#firstname').focus()           }         }).then(function (result) {             var stuff ={fn:result[0],ln:result[1], em: result[2]};              console.log(stuff);              $.ajax({                 url: url,                 type: "post",                 data: {result:json.stringify(stuff)},                 processdata: false,  // tell jquery not process data                 contenttype: false   // tell jquery not set contenttype             }).done(function( data ) {                 //console.log(data);                                 });         }).catch(swal.noop)     }); </script> 

result after using $request->all() @ controller

enter image description here


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -