dongza1708 2013-09-30 19:20
浏览 39

无法使bootstrap模态+ codeigniter一起工作

I have a bootstrap (2.3.2) modal defined as this:

<div id="myModal" class="modal hide fade">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>Modal header</h3>
  </div>
  <div class="modal-body">
  </div>
  <div class="modal-footer">
    <a href="#" class="btn">Close</a>
    <a href="#" class="btn btn-primary">Save changes</a>
  </div>
</div>

I also have a button like this:

<button type="button" data-toggle="modal" data-remote="index.php/mycontroller/methodname" data-target="#myModal">Launch modal</button>

method in controller:

public function methodname() {
      $this->load->view('modalbody');
}

If I directly use browser to access: localhost/myproject/index.php/mycontroller/methodname I can get the html without any problem, but if I click on the button, I got an 500 internal server error . Why and how to fix this?

Edit: when the modal is loaded I don't see my html got injected inside 'modal-body'. Also I digged a little deeper (by using firefox + firebug) and the internel error was 'The action you have requested is not allowed.' (when using google chrome it didn't show any detailed error msg) which has something to do with csrf_protection (I have set this to true). So which means when calling this modal, I have to pass the csrf token name and hash (ie. by using $this->security->get_csrf_token_name();), but I have looked at the bootstrap js source code, data-remote is simply calling the jQuery load function:

.load(this.options.remote)

without accepting any data, so how am I going to pass the csrf token name and hash????

  • 写回答

2条回答 默认 最新

  • douche1936 2013-10-01 12:34
    关注

    try ../index.php... or ../../index.php... for modal url...

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)