I'm using PHP Codeigniter. I have a sidebar in my website that displays every task I have in my database. In the Task table, I have a text column, that I want to be able to update when pressing enter.
What I did at the moment was to create a javascript function that gets called when pressing Enter :
function CursorKeyDown(e, id){
if(e.keyCode === 13){
var text = document.getElementById('area').value;
window.location.href = "<?php echo site_url('task/Task/validSuivi/')?>" + '/' + id + '/' + text;
//window.history.pushState('', '', "<?php echo site_url('task/Task/validSuivi/')?>" + '/' + id + '/' + text);
//alert("Enter was pressed was presses");
}
return false;
}
At the moment if I use window.location.href, it redirects to the link or where my controller wants it. What I want is to call the method, update the database, but no redirection or whatever. Is that possible ? With Ajax ? I tried something with pushstate but it just modifies the URL without triggering the method.
My method in the controller :
public function validSuivi($id_tache, $text)
{
$arr['suivi'] = $text;
$this->task_model->update(array('id_tache'=>$id_tache),$arr);
//redirect('task/task');
}
