mardi 1 janvier 2019

laravel ajax is not working , it seen fail


i want to insert data from register form by ajax.
but I see ajax failed in my console log.
I can't understand what is problem ?
here is my js :

$('#Personal_Information').on('submit', function(event){
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax
        ({
            type: "POST",
            dataType : 'json',
            url: "", 
            data: {csrf_token:"", data: form_data}
        }).done( function(data){
            console.log('Ajax was Successful!')
            console.log(data)
        }).fail(function(){
            console.log('Ajax Failed')
        });

here is my route :

Route::get('/update-profile', 'personalinformation@redirectupdatepage')->name('/all.update-profile');
Route::post('/all/update-profile', 'personalinformation@store');

my controller's code :

    public function store(Request $request)
{
    $modal = User::create($request->all());
    return $modal;
}

Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire