CodeIgniter Forums
Call ajax in Footer.php in CI 3 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Call ajax in Footer.php in CI 3 (/thread-67767.html)



Call ajax in Footer.php in CI 3 - nkhan - 04-06-2017

I want call ajax in admin panel from footer.php.

Please help me on this point......


Thanks in Advance........


RE: Call ajax in Footer.php in CI 3 - InsiteFX - 04-06-2017

So why not explain just what you want to do. that does not tell us much.


RE: Call ajax in Footer.php in CI 3 - ciadmin - 04-06-2017

Normal practice is for AJAX to "call" a method on the server, not the other way around.


RE: Call ajax in Footer.php in CI 3 - dave friend - 04-06-2017

It's not really clear what you are asking. Are you asking how to load your javascript at the bottom of the page?


RE: Call ajax in Footer.php in CI 3 - neuron - 04-06-2017

assume that u have Controller User and there is method named user_info(){...} that serves your ajax request: 
PHP Code:
class User extends CI_Controller { 

    
public function __construct() {

        parent::__construct();    
    
}
    public function user_info(){//serves ajax request
        $this->load->model('user_model');
        $user_info $this->user_model->get_user_info();
        //if your want return array:
        $data['user_info'] = $user_info;
        echo json_encode($data); //in your javacript code in your ajax request set dataType: 'json'

        // or if u want to return html data
        $this->load->view('user_info_view'$data);//in your javacript code in your ajax request set dataType: 'html'

        //if u want to return html in your as an array
        $data['user_info_html'] = $this->load->view('user_info_view'$datatrue);
//in your javacript code in your ajax request set dataType: 'json'
        echo json_encode($data);
    }
}
  

in your ajax request url: 'http.mysite.com/user/user_info'