Missing required parameters for [Route: sender] [URI: {name}/{code}] [Missing parameters: name, code]

  ajax, javascript, jquery, laravel

This may seem duplicate but I have this problem using AJAX and I dont know how to fix it.

Routes: web.php

Route::get('/{name}/{code}',[AppHttpControllersTestController::class, 'counter']);
Route::post('/{name}/{code}',[AppHttpControllersTestController::class, 'sender'])->name('sender');

Controller: TestController.php

public function counter()
        return view('room');

public function sender(Request $request)
        $xd = array(
            '1' => request('text'), 
            '2' => Request::url()
        event(new TestEvent($xd));

View: room.blade.php:

<!doctype html>
<html lang="en">
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <label for="lname">Code:</label><br>
        <input type="text" id="text" name="text"><br><br>
        <input type="submit" value="Submit">



    <script type="text/javascript">
      $("form").on("submit", function (e) {
      var data = $(this).serialize();
        type: "POST",
        URL: "{{route('sender')}}",
        data: data,
        success: function () {

The error is the AJAX if I take it out I dont get an error. The AJAX code is to call the Controller without redirecting to other page. Any idea how to fix it?

Source: Laravel

Leave a Reply