dqj5046 2015-11-04 11:40
浏览 68

如何加载CI控制器功能而不刷新视图?

When i check some league, i want to load seasons from database what i have for that league.

I tried this code.

test.php view

   <script type="text/javascript">
        $(document).ready(function () {
            var site_url = "<?php echo base_url('/system/getseasons/SC0'); ?>"; //SC0 is here as example, there will be selected league
            $("#season").load(site_url);
        });
    </script>

System.php controller

public function getseasons($div){
   $seasons = $this->sys_model->getseasonsforleague($div);
   $mode = '';
   foreach($seasons->result() as $season){
      if($season->Season != ''){
        $newseason = $this->season_filter($season->Season);
        if($mode == 'edit' and $system->bet_venue !== NULL){
        $season_arr = explode(";",$system->seasons);
          foreach($season_arr as $seas){
              if($season->Season == $seas){
                 echo "<input type='checkbox' name='season[]' checked='checked' value=". $season->Season .">" . $newseason . "</input><br>";              
              }
          }
          if($season->Season != $seas){
              echo "<input type='checkbox' name='season[]' value=". $season->Season .">" . 
              $newseason . "</input><br>";            

          }
        }
        else{
          echo "<input type='checkbox' name='season[]' value=". $season->Season .">" . $newseason . "</input><br>";     }
      }
   }
}

NOTE: this controller 100% works because when i manually go to this link: site.com/system/getseasons/SC0 i get all seasons for SC0 league.

and Sys_model.php model

public function getseasonsforleague($div){
    $this->db->select('Season');
    $this->db->where('Div',$div);
    $this->db->group_by('Season');
    return $this->db->get('historic');
}

When i check browser Console i see 404 error:

GET https://www.example.com/system/getseasons/SC0 404 (OK)send @ jquery.min.js:5m.extend.ajax @ jquery.min.js:5m.fn.load @ jquery.min.js:5(anonymous function) @ test:11j @ jquery.min.js:2k.fireWith @ jquery.min.js:2m.extend.ready @ jquery.min.js:2J @ jquery.min.js:2

But one more time, this link works:

https://www.example.com/system/getseasons/SC0

Also i tried this:

var site_url = "<?php echo base_url('/index.php/system/getseasons/SC0');

but again 404.

UPDATE: Network tab network

  • 写回答

2条回答 默认 最新

  • doupeizheng3918 2015-11-04 11:44
    关注

    try this

    ` var site_url = "<?php echo base_url(); ?>"+'/system/getseasons/SC0';`
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大