Monday, April 3, 2017

jquery.js 9557 error in laravel

This is my function where I need to make a response in ajax

function load_id_user(id){
    var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');

    alert(id);

    $.ajax({
        url: 'load-user',
        type: 'POST',
        data: {_token: CSRF_TOKEN,id:id},
        success: function (data) {
            $( "#user_fields" ).html( data );
        }
    });
}

this is my route.

Route::post('load-user','UserController@load_id');

and this is my controller

public function load_id() {

        $var=DB::select('select * from user where user_id="$_POST[id]"');

        //$var=Usuarios::select()->where("user_id","=",$_POST['id'])->get();

        foreach ($var as $user) {
            echo '<input type="text" name="cedula" value="'.$user->user_id.'" onblur="load_id_user(this.value);" placeholder="Cedula" class="form-control" required>';
        }
    }

when I try to run this the console say error 500, try everything and nothing works.



via Mhurtado

Advertisement