I do not work the .load in laravel

1

I'm trying to load a .php file into a div, I'm working with Laravel but the file does not load me, I've already tried it with raw php and it works perfectly. I already check routes and everything is fine I do not know what happens.

$(document).ready(function() {
  $('.iconStu').click(function() {
    $("#id").load('estudiantes.php');
  });
});
    
asked by Jeisson Hernandez 11.01.2018 в 22:24
source

1 answer

0

You should create a new route to access from the (Js) client to the views.

In routes.php you can have a path, with name to access from JS , the view file should have the extension of blade , estudiantes.blade.php

Route::get('estudiantes',function(){
    return view('estudiantes');
})->name('estudiantes');

Yes it is doing the load from a view directly. could print the route with route('nombreruta)

$(function() {
  $('.iconStu').click(function() {
    $("#id").load('{{ route('estudiantes') }}');
  });
});

Or if it is from an external file JS

$(function() {
  $('.iconStu').click(function() {
    $("#id").load('/estudiantes');
  });
});
    
answered by 11.01.2018 / 22:53
source