在焦点上加载Bootstrap模式中的动态内容

时间:2017-07-14 21:08:07

标签: javascript jquery ajax twitter-bootstrap bootstrap-modal

我正在尝试通过ajax在bootstrap模式中加载一个url,当模态被聚焦但是它不起作用。

模态代码

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" id="loadMediaFiles" data-target="#myMediaModal">Launch demo modal</button>
<div class="modal fade" id="myMediaModal">
<div class="modal-dialog" role="document">
    <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">Media</h4>
       </div>
       <div class="modal-body" id="mediaFilesResult">
          <div class="text-center">
              <i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>
         </div>
       </div>
       <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
  </div>

的Javascript

$('#loadMediaFiles').focus(function () {
    $.ajax({
        url: '/Uploads/Browse',
        contentType: 'application/html; charset=utf-8',
        type: 'GET',
        dataType: 'html'
    })
    .success(function (result) {
        $('#mediaFilesResult').html(result);
    })
});

我做错了什么,我需要帮助。感谢

0 个答案:

没有答案