【问题标题】:Laravel 4 Modal Ajax doesnt workLaravel 4 模态 Ajax 不起作用
【发布时间】:2015-08-26 11:20:27
【问题描述】:

我有使用 Laravel 4 在 Modal Bootstrap 中调用其他页面的代码。但是在模态中不会出现其他页面。以下是我的 javascript 代码:

<script>
    $(function() {
        //ambil data untuk detail buku
        $(".detail-dialog").click(function() {

             $('#container-modal-ajax')                              
             .dialog({
                 modal: true, 
                 title: 'Rincian Buku',
                 shadow: true,
                 show:{ effect: "puff", duration: 500 },
                 hide:{ effect: "puff", duration: 1000 },
                 overlay: true,
                 draggable: true,
                 open: function(){
                    $.ajax({
                        url: "/user/home"                          
                    });
                },    
                 buttons: [
                    {
                      text: "ok",
                      click: function() {
                        $( this ).dialog( "close" );
                      }
                    }
                  ]                             
             });

             $("#dialog").load("detail.php", function() {

            });
        });

    });
</script>

如果我在 url ajax 部分写下控制器路由是真的吗?

【问题讨论】:

    标签: php ajax laravel-4


    【解决方案1】:

    看起来你正在使用 jQuery 进行 AJAX 调用,根据他们的文档默认为 GET 请求。

    所以你需要确保你有一个 /user/home 的路由设置

    一个示例路线是:

        Route::get('/user/home', function()
    {
        return 'User home';
    });
    

    【讨论】:

      猜你喜欢
      • 2018-11-25
      • 2013-10-10
      • 2018-05-07
      • 2013-05-17
      • 1970-01-01
      • 2019-08-01
      • 2012-12-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多