vincej

AJAX: Can not get data into controller

Posted 6 months ago by vincej

This is for me a major mystery. I have tested everything.

The form data is coming through nicely. My route checks out perfectly. The success function works fine, however for some dumb reason on my part, for sure, my controller is not receiving the data. Many Thanks for your continued help !

Javascript / AJAX

$("#editsubmit").click(function () {
        event.preventDefault();
        var formData = $("#formData").serialize();
        var id = $("#reference").val();

        $.ajax({
            headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
            type: "POST",
            url: '/quote_edit/save_edit/' + id,
            data: {data:formData},
            success: function () {
                localStorage['alert'] = 'true';
                location.href = "/open_quotes"
            },
            error: function () {
                alert('there has been a system level error - please contact support')
            }
        });
    });

**My Controller: **

public function save_quote_edited(Request $request){
        
        dd($request);   // I have tried them individually, and None of these dd() work. 
        
        dd($request->data);
        
        dd($request->get('data'));
        
        }


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

Reply to

Use Markdown with GitHub-flavored code blocks.