Welcome Guest, Not a member yet? Register   Sign In
Call ajax in Footer.php in CI 3
#1

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

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


Thanks in Advance........
Reply
#2

So why not explain just what you want to do. that does not tell us much.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

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

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

(This post was last modified: 04-06-2017, 11:19 PM by neuron.)

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'
Reply




Theme © iAndrew 2016 - Forum software by © MyBB