My problem is when I use ajax to POST
, in Controller
after I gather data in Model
my next step is to access the View
but unfortunately its not working, I only view it in inspect element in firefox.
This is my sample code:
public function view_generate_jo_number()
{
$jo_num = $this->input->post('jo_num');
$view_generated = $this->project_models->view_generate_jo_number($jo_num);
$this->load->view('templates/header');
$this->load->view('jo_generated_project_views', $view_generated);
$this->load->view('templates/footer');
}
So I think again for another solution which is I have this ajax..when in success it will redirect to another function within the same controller.
$("#view").click(function()
{
$.ajax({
url : '<?php echo base_url('jo_generator/view_generate_jo_number')?>',
type: 'POST',
data: {
jo_num: $('#new_jo').text()
},
success: function(data){
$.ajax({
url : '<?php echo base_url('jo_generator/view_jo_number')?>',
success: function(){
}
});
}
});
});
But my problem is in my first controller:
public function view_generate_jo_number()
{
if ($this->jo_generator_security_models->isAllowedToViewGenerateJO() === TRUE)
{
$jo_num = $this->input->post('jo_num');
$view_generated = $this->project_models->view_generate_jo_number($jo_num);
}
}
I want to get the variable $view_generated so that I can use it in another function which is this:
public function view_jo_number($view_generated)
{
$this->load->view('templates/header');
$this->load->view('jo_generated_project_views', $view_generated);
$this->load->view('templates/footer');
}
Because I need that variable to view the data in views.
Is there a way I can access it using success in ajax
or I will call the variable from another function?
Can someone help me with this?