weixin_33697898 2017-05-23 17:36 采纳率: 0%
浏览 33

如何在Laravel中使用Ajax?

Guys i have made a blog using Laravel framework, today I just heard about ajax, What I heard is in short: it loads data quickly. My issue is that I have many routes , controllers with views.

What steps do i need to use so called ajax javascript?

  <script>

   $.ajaxSetup({
    headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') 
  }
  });

  jQuery.ajax({
    url:'/blog',
    type: 'GET',

    success: getIndex(  ){

        console.log( );
      },

  });

 </script>
  • 写回答

2条回答 默认 最新

  • weixin_33730836 2017-05-23 18:35
    关注

    Ajax can be used normally in Laravel, I particularly usually host my codes in '/ public / js' and then extend through the <script> so that the code is not mixed. I advise you to study Laravel's structure, read the documentation, see some videos. Your question is very broad, so I will leave some materials that are of interest to you.

    Book by Novatec about Ajax:

    https://www.novatec.com.br/livros/ajaxjquery/

    Laravel Docs:

    https://laravel.com/docs/5.4/

    评论

报告相同问题?