动态模式不加载数据

时间:2018-08-02 12:12:43

标签: ajax laravel modal-dialog

我有一个Modal可以动态显示数据,但是它不起作用,并且我的项目中有相同的Modal可以正常工作,但是我创建的这个新数据却不起作用...

  

在控制台中收到http://127.0.0.1:8000/hr/received/receiveReprt/3 404(未找到)错误

功能:

public function receiveReprt($id)
    {
        $reprt = shareReport::select('content')->where('id','=',$id)->first();
        return $reprt;
    }

路线:

Route::get('/receiveReprt/{id}','HrController@receiveReprt');

AJAX:

$('a.view').click(function(){
    var id = $(this).attr('data-id');
    var url = 'receiveReprt';

      $.get(url + '/' + id, function (data) {
            //success data
            console.log(data);
          $("#previewdoc").html(data.content);
          $('#viewModal').modal({show:true}); 

        }); 

  });

模式:

<div class="modal fade" id="viewModal" tabindex="-1" role="dialog">
  <div class="modal-dialog modal-dialog-centered" style="width:60%;">
   <div class="modal-content">
    <div class="modal-header">
     <h4 class="modal-title"><center>Preview</center></h4>
      </div>
    <div class="modal-body" id="previewdoc" style="padding: 40px;">
    </div>
    <div class="modal-footer">
        <button class="btn btn-danger" type="button" data-dismiss="modal">
            <span class="fa fa-times-circle"></span> Close
        </button>
      </div>
         </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

我认为问题出在型号名称上

public function receiveReprt($id)
        {
            $reprt = shareReport::select('content')->where('id','=',$id)->first();
            return $reprt;
        }

   public function receiveReprt($id)
            {
                $reprt = ShareReport::select('content')->where('id','=',$id)->first();
                return $reprt;
            }