mardi 2 octobre 2018

Laravel POST405 (Method Not Allowed) from ajax call

I have a page that is successfully loaded by GET method.

Laravel route for loading the page:

Route::get('editeazaOferta/{id}', 'OfertaNouaController@edit');

From this page I try to launch a POST Ajax like this:

    $('#latimeAnvFata_modif').change(function() {

        var latimeAnvelopa = $('#latimeAnvFata_modif option:selected').text();    

        $.ajax({
            url: "ajaxGetInaltimeAnvelope",
            type: "POST",
            data: {latimeAnvelopa:latimeAnvelopa},
            success: function (msg) {
                $('#inaltimeAnvFata_modif').html(msg);
                setAnvelope(0,0);
            },
            error: function (msg) {
            }
        })
    })

I have the corresponding POST route:

Route::post('ajaxGetInaltimeAnvelope','AjaxController@getInaltimeAnvelope');

When Ajax is triggered I get the following error:

"jquery-3.3.1.js:9600 POST https://ofertare2.topl.ro/editeazaOferta/ajaxGetInaltimeAnvelope 405 (Method Not Allowed)"

I think the route is OK because I successfully use the same Ajax with the same route from another page, the only difference is that another page is loaded by a POST request.

Is this something linked to CORS? And if it is how can I enable on Laravel 5.4 / Apache 2.2.4



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire