Welcome Guest, Not a member yet? Register   Sign In
How to use jquery .load function in codeigniter?
#1

[eluser]Siyavash[/eluser]
the title describes what Im searching for:
Is there any way I can use .load() function of JQUERY ?
It is not working at all!

I tried this line of code but it did not respond :
Code:
$('#content').load("<?php echo site_url('main_index/load_view'); ?>");

and this is my load_view function inside my default controller (main_index) :
Code:
function load_view()
    {            
            $this->load->view('register_admin_view');    
    }
#2

[eluser]marjune[/eluser]
Code:
$('#content').load("<?php echo base_url().'index.php/main_index/load_view' ?>");
#3

[eluser]Siyavash[/eluser]
this was not the answer!
It seems that there should be a special way of using .load() function of jquery in CI!
#4

[eluser]marjune[/eluser]
what do you want to do with your load function then?
#5

[eluser]Siyavash[/eluser]
The exact thing that I want to do is :
Load a .php file from my views folder into a div tag. thats all !
ps : it doesnt differ using .load or .html or .ajax or .append... I just want to load a .php view in a div tag.
#6

[eluser]marjune[/eluser]
alright

Code:
$('#content').load("<?php echo base_url().'index.php/main_index/load_view' ?>");
  

<div id = "content">

</div>
#7

[eluser]Siyavash[/eluser]
Not Working.
Sad
#8

[eluser]Siyavash[/eluser]
BTW may a view file be loaded directly , not by a controller ?
I am trying to load a view from a load_view function in my controller and I think some error is raising just there .
#9

[eluser]Seb[/eluser]
The view files are only to be used by controllers.

However, your "load" with jQuery as mentioned in your first post should be working.

First try to get in your browser the URL "main_index/load_view", and then check if everything works as expected or fix any error.
#10

[eluser]Siyavash[/eluser]
thanks for your replies.
I solved the problem. It was a little mistake of my controller code.




Theme © iAndrew 2016 - Forum software by © MyBB