duanbu1998 2014-07-17 20:19 采纳率: 0%
浏览 89

如何通过laravel中的ajax / jquery将blade或php内容加载到视图中?

As the title says, I am trying to dynamically load content in a view using ajax requests. I know this can be done if you are using html elements e.g. ("#div_place").html(<p>...). The problem lies when I would like to load some php/blade objects into a div for instance. Is this possible or is there a different way to go about achieving the result I want.

  • 写回答

2条回答 默认 最新

  • dougang1965 2014-07-17 21:04
    关注

    After some digging some more I found this which helped me to solve the problem.

    You have to use the .load("url/page/...") via jquery and then set a route in the routes.php file that displays a view with the data that needs to be loaded e.g.

    Route::get('/url/page/...', function(){
        return View::make('test');
    });
    

    This returns the necessary php code which needed to be loaded dynamically, cheers.

    评论

报告相同问题?