使用CodeIgniter将数据从视图传递到URL中的控制器

时间:2015-05-20 21:44:13

标签: php codeigniter model-view-controller

我有一个视图,我希望在按下按钮时,将数据发送到控制器中的特定功能,然后稍微操作它并将其传递到另一个视图。但是,无论何时按下按钮,屏幕都是空白的。该网址会更改为正确的网址,但在Chrome开发者工具中,它会显示:

 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

错误。我不确定什么是无法加载,或者发生了什么。非常感谢任何帮助!

我的观点(相关部分):

<script>
    $('#begin_practice').on('click', function(){
      location.href= "<?php echo base_url() . 'test/setupTest/' . $test_id . '/' . $lang . '/' . $practice; ?>";
    });
</script>

我的控制器(相关功能):

public function setupTest($test_id, $lang, $practice){

  $this->load->model('Test_model');
  $test_key= ($practice) ? $this->Test_model->getKey($test_id, $lang, $practice) : $this->Test_model->getKey($test_id, $lang, $practice);

  $data['test_key'] = $test_key;
  $data['test_id'] = $test_id;
  $data['lang'] = $lang;
  $data['practice'] = $practice;

  if($practice){
    $this->load->view('tests/test_sample/' . $lang . 'practice_test_view', $data); 
  }else{
    $this->load->view($lang . '/test_view', $data);
  }
}

我的模特:

public function getKey($test_id, $lang, $practice){

  if($test_id == 7){
    $image_array = ($practice) ? $image_array = file_get_contents('<?=base_url();?>files/json/task_' . $test_id . '_practice_' . $lang . '.json') : $image_array = file_get_contents('<?=base_url();?>files/json/task_' . $test_id . '_' . $lang . '.json');
  }else{
    $image_array = ($practice) ? $image_array = file_get_contents('<?=base_url();?>files/json/task_' . $test_id . '_practice.json') : $image_array = file_get_contents('<?=base_url();?>files/json/task_' . $test_id . '.json');
  }
  $image_array = json_decode($image_array, true);
  if($test_id !=8){
    shuffle($image_array);
  }

  return $image_array;
}

如果还有其他需要,请告诉我。提前谢谢!

0 个答案:

没有答案