【发布时间】:2015-07-10 16:01:44
【问题描述】:
我有一个使用外部 js 文件显示测验的视图。测验完成后,我将一些新的 html 附加到屏幕上,包括一个新按钮,该按钮假定在被单击后会将用户发送到我的主控制器的 practiceTask 函数。但是,当它被点击时,我得到了错误:
Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'practiceTask'
因为代码在 .js 文件中,据我所知,我不能使用 site_url 或 base_url。这是正确的方法吗?
相关JS:
$('#imageLocation').attr("src", "");
var html = '<div class="instruction_block"><p class="instruction_text" style="text-align: center; margin-top: 0">You have completed the ' + text + ' test</p><div class="button_placement" style="margin-top: 300px;"><input class="rounded" style="position: absolute; bottom: 0; right: 0; width: 250px;"" type="button" value="Continue to the next task" onClick="/main/practiceTask/3"></div>';
$('#final_message').append(html);
主控制器功能:
public function practiceTask($task_id){
$this->load->model('Main_model');
echo ($task_id);
$json_key = $this->Main_model->getKey($task_id);
$json_key = json_decode($json_key, true);
shuffle($json_key);
$data['test_key'] = $json_key;
$data['task_id'] = $task_id;
$this->load->view('practice_test_view', $data);
}
任何帮助将不胜感激!
【问题讨论】:
标签: javascript php codeigniter model-view-controller web