G
G
Givi7772019-09-06 14:51:34
JavaScript
Givi777, 2019-09-06 14:51:34

How to accept response in controller?

@foreach($lessons[0]['lessonTest']['question'] as $question)
                <div @if($test_count == 1){{$data_test}}@endif>
                    <h6 class="question">Упех компании во многом зависет от четкости их формулирования и своевременности донесения до персонала или нет?</h6>
                    <form id="12345" method="post" enctype="multipart/form-data" action="{{route('pass-test')}}">
                        {!! csrf_field() !!}
                        @foreach($question['answers'] as $answer)
                            <label >
                                <input type="radio" name="answer" value="1">
                                <span>{{$answer['answer']}}</span>
                            </label>
                        @endforeach
                    </form>
                </div>
            @endforeach

$.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                dataType: 'JSON',
                method: 'POST',
                url: '/rules/manager/pass-test',
                data: {
                    answers
//                    '1': 'test'
                },
                success: function(response) {
                    var answers = $.parseJSON(data)
                    console.log(888, response);
                }
            });
        });

public function passTest(Request $request)
    {
        dd(response()->json());

    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question