I have an ajax call from my javascript file that is attempting to post data to a specific function in my controller. When I view the data in the success function of my call, I get the html of a totally unrelated view as the returned data, and I am unsure why.
My AJAX call:
function processResults(task_id){
var finalResults = localStorage.getItem('results');
console.log(finalResults);
$.ajax({
type: 'POST',
url: 'task/getResults',
data: {'answers': finalResults},
success: function(data){
console.log(data);
}
});
}
My Controller function:
public function getResults(){
$this->load->model('testResults');
$finalResults = $this->input->post('answers');
$finalResults = json_decode($finalResults, true);
if ($taskTestId != '') {
$this->testAnswers->insertTaskData($finalResults);
}
}
Is the url in the ajax call incorrect? I'm not really sure why it is outputting the html of a completely unrelated view. Any help would be appreciated!