Welcome Guest, Not a member yet? Register   Sign In
Codeigniter and ajax query involving one more view
#1

I am trying to call an AJAX output involving classic MVC scheme. My jquery method is communicating with controller and I can catch the variables sent by the jquery. What ever is being printed in the contoller is correctly showing back in jquery alert box ... However I can not get to my jquery method anything from the view called by the controller which is supposed to generate the ajax output. I know that I can simply printout all in the controller I just don't feel comfortable to generate an HTML view in controller.  
I ma using a codeigniter 2.
This is the calling jquery method in my view:
Code:
$.ajax({
       type: "POST",
       url: "<?php echo base_url();?>admin/get_promos/",
       cache: false,
       data: {promos_id: JSON.stringify(jsonObj)},
       success: function(data){
              alert(JSON.stringify(data));
       }
   });
Here is my controller :
Code:
public function get_promos(){
       if (!$this->input->is_ajax_request())
       {
           exit('No direct script access allowed');
       }
       else {
           $data['promos_id'] = $this->input->post('promos_id');
           echo $data['promos_id'];
           $this->view->load('list_promo_estab_ajax', $data);
       }
   }
And here is my view 'list_promo_estab_ajax.php' which I am trying to load in the above controller, but nothing gets back to my jquery method :
Code:
<?php
echo 'basic blah';
?>
Reply
#2

(This post was last modified: 12-29-2015, 02:09 AM by sintakonte.)

just out of curiosity

you wrote: $this->view->load('list_promo_estab_ajax', $data);

shouldn't it be $this->load->view('list_promo_estab_ajax', $data);

or was it a typo? Wink

check that @first, if it doesn't change - i might have another idea
Reply
#3

Of coz it was the typo and "basic blah" is back on track . 
Thx for crawling through my mistakes Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB