mardi 25 juin 2019

404 error for ajax get request in laravel

Controller:

class AjaxController extends Controller
{
    public function moreassignment(Request $request){
        if ($request->ajax()) {
            return view('ajax.assignment');
        }
    }
}

Route/Web:

Route::get('getassignmentform', 'AjaxController@moreassignment');

Ajax call:

$(document).ready(function(){
    $('.add_more_assignment').click(function(e){
        e.preventDefault();
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
            }
        });
        $.ajax({
            url: "",
            method: 'get',
            success: function(result){
                console.log(result);
            }});
    });
});

This is very simple and straightforward ajax request but I am getting the following error:

jquery.min.js:4 GET http://pms.local/ajax/moreassignment 404 (Not Found)

Whats wrong is going on?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2NaOrba
via IFTTT

Aucun commentaire:

Enregistrer un commentaire