AJAX POST request throws "MethodNotAllowedHttpException No message" error right after I submit it

Posted 4 months ago by Gabotronix

Hi, I'm trying to make the basic subscription service, sasly laravel is throwing the following error right after I submit the form via AJAX POST request:

 Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
No message

What could be the cause of this?


Route::post('/subscripcion', '[email protected]')->name('sub');

JQuery code:

        var form = $(this).closest('form');
        console.log('button start subscription clicked');
        var emailval=$("input[name='email']").val();
            headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')}
            async: true,
            cache: false,
            url: '{{ route('sub') }}',
            type: 'POST',
            'email': emailval
            dataType: 'JSON',
            success: function (data) { 
                $('.form_valid_container').html('<span class="form_valid_text">✓ '+ data.success +'</span>');
            error: function (data){
                var errors = data.responseJSON;
                $.each(errors , function(){
                    $('.form_error_container').html('<span class="form_error_text">✘ '+ errors.message +'</span>')



My view:

<section class="section_sub_mino_maincontainer" style="width:100%; height:200px; display:flex; flex-direction:column;  justify-content:center; align-items:center; ">
    <form class="section_sub_mino_form_container" method="POST" style="width:auto; height:auto; display:flex; flex-direction:column; align-items:center;">
        <span class="section_sub_mino_form_title" style="font-size:24px; color:rgba(0,0,0,0.7); margin:10px 0px; font-weight:600;">Subscribete para recibir nuestras últimas ofertas, noticias y mucho más</span>
        <div class="section_sub_mino_form_newsletter_container"  style="width:400px; height:40px; outline:1px solid rgba(0,0,0,0.3); display:flex; margin:10px 0px;">
            <input class="section_sub_mino_form_newsletter_input" style="width:80%; height:100%; padding:10px;" type="text" name="email" placeholder="Tu correo electrónico">
            <button class="section_sub_mino_form_newsletter_button startSubscription" style="height:100%; padding:0px 15px; font-size:18px; text-transform:uppercase; display:flex;background-color:var(--web_primary_color); color:white;  align-items:center; ">SUBSCRIBIRME</button>
        <div class="form_valid_container"></div>
        <div class="form_error_container"></div>



namespace App\Http\Controllers;

use App\Emails;
use Illuminate\Http\Request;
use App\Http\Requests\StoreSubbedMail;

class SubscriptionController extends Controller
    public function index()

    public function create()

    public function store(StoreSubbedMail $request)
        $email = new Emails();
        $email->subbed_mail = $request->email;
        return response()->json(['success'=>'Te subscribiste correctamente!'], $email);

Form request:


namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreSubbedMail extends FormRequest
     * Determine if the user is authorized to make this request.
     * @return bool
    public function authorize()
        return true;

     * Get the validation rules that apply to the request.
     * @return array
    public function rules()
        return [
            'subbed_mail' => 'required|email|unique:emails',

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.