njlqay njlqay - 2 months ago 15
jQuery Question

Load php page into view via jQuery load() in CodeIgniter

I need to refresh div contents with single php pages via jQuery.

Without CodeIgniter it works in jQuery like this:


$(".myDIV").load("my_page.php");


As I am using CodeIgniter I tried to solve it with setting the base_url but it does not work:


$(".myDIV").load("<?php echo base_url()."application/views/my_page.php"; ?>");


How do I call the include request via jQuery correctly?

Answer

In controller My_page_ctrl.php

    public function index(){
        $this->load->view('my_page');
    }

In javascript

$(".myDIV").load("<?php echo base_url().'my_page_ctrl'; ?>");

Try this one. This will work fine.