当我查看一些联赛时,我想从数据库中加载我对该联赛的季节。
我尝试了这段代码。
test.php视图
<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控制器
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>"; }
}
}
}
注意:此控制器100%有效,因为当我手动转到此链接时: site.com/system/getseasons/SC0我得到SC0联赛的所有赛季。
和Sys_model.php模型
public function getseasonsforleague($div){
$this->db->select('Season');
$this->db->where('Div',$div);
$this->db->group_by('Season');
return $this->db->get('historic');
}
当我查看浏览器控制台时,我看到 404 错误:
GET https://www.example.com/system/getseasons/SC0 404(OK)发送@ jquery.min.js:5m.extend.ajax @jquery.min.js:5m.fn.load @ jquery.min.js:5(匿名函数)@test:11j @ jquery.min.js:2k.fireWith @jquery.min.js:2m.extend.ready @ jquery.min.js:2J @jquery.min.js:2
但又一次,这个链接有效:
我也试过这个:
var site_url = "<?php echo base_url('/index.php/system/getseasons/SC0');
但又是404。
答案 0 :(得分:0)
试试这个
` var site_url = "<?php echo base_url(); ?>"+'/system/getseasons/SC0';`
答案 1 :(得分:0)
试试这个:
var site_url = "<?php echo base_url(); ?>"+'system/getseasons/SC0/';