在Laravel中使用ajax创建图像库模板

时间:2017-08-04 06:54:49

标签: javascript css ajax laravel modal-dialog

我正在尝试创建图像单击模式打开时的图像厨房,但是当我加载我的页面片刻时,显示了奖章的内容,我不想要它如何修复它? view.blade.php中的我的代码是:

 class PermittedRoles:
    admin = 'ADMIN'
    general_user = 'GENERAL_USER'
    reports_only = 'REPORTS_ONLY'
    instagram_advertiser = 'INSTAGRAM_ADVERTISER'
    instagram_manager = 'INSTAGRAM_MANAGER'
    fb_employee_dso_advertiser = 'FB_EMPLOYEE_DSO_ADVERTISER'

此外,我想从模块中的Controller发送json信息我的控制器有此代码:

<script>
   $(".li-img").click(function () {
    $.ajax({
        method: 'GET',
        url: './comment?media_id=' + this.id,
        success: function (data) {
            /*$("#comments").html(data);**/
            $("#getCodeModal").modal("toggle");
            $("#getCode").html(data);

        }
    });
   });
 </script>
  <body>
    @foreach($array as $img)
     <div class=" portfolio-container text-center">
    <ul class="portfolio-list" style="margin:0 auto">
         <li id = "{{$img['id']}}" class="li li-img" style="margin:0 
             auto">
            <img id="{{$img['id']}}" src="{{$img['image']}}">
         </li>
    </ul>
   </div>
   @endforeach
   <div class="modal fade" id="getCodeModal" tabindex="-1" role="dialog" 
    aria-
    labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-
           label="Close"><span aria-hidden="true">&times;</span>
            </button>
        <h4 class="modal-title" id="myModalLabel"> API CODE </h4>
        </div>
        <div class="modal-body" id="getCode" style="overflow-x: scroll;">
        //ajax success content here.
       </div>
    </div>
</div>

我想在view.blade.php发送$ res-&gt; getbody()到模态

1 个答案:

答案 0 :(得分:0)

因为您没有将bootstrap添加为依赖项。

将其添加到head标签:

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

我发现您丢失了一个关闭标记</div>,其中div有一个类modal