Javascript 引导模式在提交时不会关闭

Javascript 引导模式在提交时不会关闭,javascript,php,jquery,twitter-bootstrap,Javascript,Php,Jquery,Twitter Bootstrap,我在页面中添加了一个引导模式。以下是modal div的代码: <div class="modal fade" id="myModal<?php echo $kategori['C_ID'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel<?php echo $kategori['C_ID'];?>"> <div class="modal-dialog" role="docu

我在页面中添加了一个引导模式。以下是modal div的代码:

<div class="modal fade" id="myModal<?php echo $kategori['C_ID'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel<?php echo $kategori['C_ID'];?>">
  <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<?php echo $kategori['C_ID'];?>">Perditeso</h4>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label for="id">ID</label>
          <input type="text" class="form-control" id="id<?php echo $kategori['C_ID'];?>" value="<?php echo $kategori['C_ID'];?>">
        </div>
        <div class="form-group">
          <label for="newname">Kategoria</label>
          <input type="text" class="form-control" id="newname<?php echo $kategori['C_ID'];?>" value="<?php echo $kategori['C_Name'];?>">
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Mbyll</button>
        <button type="button" onclick="catupdate('<?php echo $kategori['C_ID'];?>')" class="btn btn-primary">Ruaj ndryshimet</button>
      </div>
    </div>
  </div>
</div>

该函数正确运行并完成操作,但不会自动关闭。在这种情况下,我试图编辑那里的数据。PHP代码没有问题。

单击后,应使用以下命令以编程方式关闭模式:

$('[id^="myModal"]').modal('hide');
//OR
$('.modal').modal('hide');
success
功能内部或在功能开始时
catupdate
to,例如:

success: function(html){
   $('.modal').modal('hide');
   $('#del').html(html);
}

希望这能有所帮助。

单击后,您应该使用以下方法以编程方式关闭模式:

$('[id^="myModal"]').modal('hide');
//OR
$('.modal').modal('hide');
success
功能内部或在功能开始时
catupdate
to,例如:

success: function(html){
   $('.modal').modal('hide');
   $('#del').html(html);
}

希望这有帮助。

使用以下语法隐藏模态:

$('#modalID').modal('hide');
因此,在您的代码中:

function catupdate(id){
 var dataString="fshij=" + id;
  $.ajax({
    type:"post",
    url:"../functions/query.php",
    data:dataString,
    cache:false,
    success: function(html){
      $('#del').html(html);
      $('.modal:visible').modal('hide');
    }
  });
 return false;
}

使用以下语法隐藏模态:

$('#modalID').modal('hide');
因此,在您的代码中:

function catupdate(id){
 var dataString="fshij=" + id;
  $.ajax({
    type:"post",
    url:"../functions/query.php",
    data:dataString,
    cache:false,
    success: function(html){
      $('#del').html(html);
      $('.modal:visible').modal('hide');
    }
  });
 return false;
}

谢谢我使用了
$('#modalID').modal('hide')并且工作得很好。谢谢!我使用了
$('#modalID').modal('hide')和工作完美。这个:
$('modalID').modal('hide')工作。谢谢@布莱伦你能接受我的回答吗?我会很高兴也很感激你<代码>:)
这个:
$('modalID').modal('hide')工作。谢谢@布莱伦你能接受我的回答吗?我会很高兴也很感激你<代码>:)