I have a view in which a quiz is displayed using an external js file. When the quiz is completed, I am appending some new html to the screen, including a new button that is suppose to, upon being clicked, send the user to the practiceTask function of my Main controller. However, when it is clicked I get the error:
Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'practiceTask'
Because the code is in .js file, I can't use site_url or base_url, as far as I know. Is this the correct way to do this?
Relevant 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);
Main Controller function:
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);
}
Any help would be much appreciated!
Aucun commentaire:
Enregistrer un commentaire