lundi 5 février 2018

ajax request is not returning back to view in laravel 5

I wanted to submit a for using ajax call in laravel 5.

In view i wrote something like

$("#updateSubmit").on('submit',function(e){
e.preventDefault();
var csrfToken = $('meta[name="csrf-token"]').attr("content");
$.ajax({
            method:'POST',
            url: '/account/updateForm',
            //dataType: 'json',
            data: {accountId:'1111', _token:   ''}, 
            success: function( data )
            {
                alert(data)
                    return false;
                }
            },
    error: function(error ){
      alert("There is some error");
    }
});

and on controller side

public function update(Request $data )
{
    return Response()->json(['success' => true],200);
}

while in route for post method

 Route::post('account/updateForm', 'AccountController@update')->name('account/updateForm');

its working till ajax. on Submission of ajax it goes to controller action. but it does not retrun back as ajax comes back in normal form submisson.

it just go to controller and stops there with {"success":true} line.

I want ajax to come back to view form so that I can perform different dependent actions.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire