#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171

    Not sure why code loads the "view"!


    Hi;

    I use Jquery to load a contoller in a div. The page that I load is here

    But when I try to reload another controller in a div using Jquery ( from the bottom of this page where it says view more ads,,,please scroll down to see the link )it loads the header and footer as well! But the controller does not include header or footer.

    What is going on?

    Here is my controller
    PHP Code:
    class More_ads extends CI_Controller {

        
        public function 
    index($id)
            {
                
                if(!
    is_numeric($id))
                    {
                        exit();
                    }    
                    
                
    $this->load->model('model_ads');
                
    $data['results'] = $this->model_ads->list_haves_more($id);
                
    $data['page_title'] = "Find Share Accommodation and Flatmates on The Gold Coast";
                
    print_r($data['results']);
                
    //$this->load->view('view_header', $data);
                //$this->load->view('view_more', $data);
                //$this->load->view('view_footer', $data);
                
            
    }
         

    Code:
    <script type="text/javascript">
    	function view_more(id)
    		{
    			$.post('http://test.goldcoast-flatmates.com/more_ads/'.id, { id: id, <?php echo $this->security->get_csrf_token_name();?>: '<?php echo $this->security->get_csrf_hash();?>'},function(output){$('#short_list').html(output).show();});
    		}
    	
    </script>
    	
    	<button type="button" class="btn btn-primary btn-lg" onclick="view_more(<?php echo $last;?>)">View More Ads</button>
    	
    	<div class="center-block">
    		<div id="short_list"></div>
    	</div>
    Thanks
    Last edited by English Breakfast Tea; December 16th, 2013 at 10:49 PM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,972
    Rep Power
    375
    in your controller you are not even calling the view that render the result in a nice formatted way when you click "view more" so possibly the controller route/name is somewhere else perhaps?
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by paulh1983
    in your controller you are not even calling the view that render the result in a nice formatted way when you click "view more" so possibly the controller route/name is somewhere else perhaps?
    That's right. I am not calling any views but it loads views! I can't find it in the code, going crazy!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,972
    Rep Power
    375
    maybe your changes havent been saved on server yet?
    i.e. i see you do this

    //$this->load->view('view_header', $data);
    //$this->load->view('view_more', $data);
    //$this->load->view('view_footer', $data);

    but maybe you didnt push your changes to server?

    maybe there is a default thing that happens for each controller? impossi
  8. #5
  9. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by paulh1983
    maybe your changes havent been saved on server yet?
    i.e. i see you do this

    //$this->load->view('view_header', $data);
    //$this->load->view('view_more', $data);
    //$this->load->view('view_footer', $data);

    but maybe you didnt push your changes to server?

    maybe there is a default thing that happens for each controller? impossi
    JS was the problem! I was using "dot" to concat! With "+" it works.

    Thanks



    javascript Code:
    function view_phone_number(id)
    			{
    				$.post('http://test.goldcoast-flatmates.com/phone_number/index/'+id, { id: id, csrf_GCFEL: '8b9635c4897d3c780744e3b9e4985130'},function(output){$('#phone_number').html(output).show();});
    			}

IMN logo majestic logo threadwatch logo seochat tools logo