jeudi 16 février 2017

Laravel Ajax Request returns error 500

I am trying to create an Ajax request in laravel, but I run into 500 (Internal Server Error). Here is the route that I created:

Route::post('/ajaxtest', 'PagesController@update');

This is the update function, it currently does nothing.

public function update(Illuminate\Http\Request $request)
{
    // if ($request->isMethod('post')){    
 //        return response()->json(['response' => 'This is post method']); 
 //    }

 //    return response()->json(['response' => 'This is get method']);
}

And this is the jquery code

function tryajax() {
$.ajax({
    type: "POST",
    url: './ajaxtest',
    data: "",
    success: function() {
        console.log("Geodata sent");
    }
})

};

There is an onclick function on a button.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lngSDh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire