Greetings, I am presenting a difficulty using ajax
in Laravel 5.4
, jQuery v3.2.1
and Bootstrap v3.3.7
to bring information.
I have done the following:
In the File web.php the route was created: Route::resource('workshop', 'WorkshopController');
when using php artisan route: list
POST | workshop | workshop.store GET | HEAD | workshop | workshop.index GET | HEAD | workshop / create | workshop.create PUT | PATCH | workshop / {workshop} | workshop.update GET | HEAD | workshop / {workshop} | workshop.show DELETE | workshop / {workshop} | workshop.destroy GET | HEAD | workshop / {workshop} / edit | workshop.edit
In the view:
$(document).ready(function(){
$(".open_modal").click(function(){
$("#myModal").modal("show");
$.ajax({
url: ruta + '/' + 'workshop.create',
type:'get',
dataType: 'json',
success: function(result){
$('#views').modal('show').html(result.vista);
},
error: function( jqXHR, textStatus, errorThrown ) {
alert(" Posible error: " + errorThrown + " Estatus :" +
textStatus);
},
});
});
});
In the create method of the controller WorkshopController
is like this:
public function create(Request $request)
{
$workshops = Workshop::all();
$html = View::make('workshop.create',array('workshop'=>$workshops))-
>render();
return response()->json(['vista' => "$html" ]);
}
Return me:
Possible error: SyntaxError: Unexpected end of JSON input Status: parsererror
What alternatives could you give me!