1

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?

5
  • load the controller ? Commented Sep 12, 2016 at 12:01
  • $(".myDIV").load("<?php echo base_url(); ?>controller_name/function_name"); Commented Sep 12, 2016 at 12:01
  • Normally you wouldn't load a view, you would load the controller. If you're using routes, you would do <?php echo base_url()."/my_page"; ?> or something. Commented Sep 12, 2016 at 12:02
  • what is your controller name? Commented Sep 12, 2016 at 12:03
  • 1
    Thanks to all replies! Helped me to solve this issue. Just call the controller and there load the view. Commented Sep 12, 2016 at 13:10

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

just call the name of function in controller

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


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

It works !

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.