There are a lot of solution for this question.
But I dont know why my code doesnt work.
What I want :
Data Array -> ajax post -> codeigniter controller(save data in DB and redirect to another page)
function postData(){
// Generate final Array Code
//then Post
$.ajax({
type: "POST",
url: "<?php echo site_url('c/myController/')?>",
data: {values:finalArray},
success: function(msg){
alert(msg);
}
});
}
<button id="submitJson" onclick="postData()">Submit</button>
In my Controller :
function myController()
{
//insert into db as per rule
$data = "";
//then redirection
$this->load->view('c/redirectionPage', $data);
}
I dont know why its not working. I tried direct url it works and also ajax success function gives alert message.
Thanks in advance.
actionseems more fitting for this problem.