CodeIgniter Forums
Ajax load - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Ajax load (/showthread.php?tid=60282)



Ajax load - El Forum - 02-21-2014

[eluser]htarahi[/eluser]
Hi friends ,
I have 2 kinds of page's.
1 kind are the pages that will show normally.I mean with click on related link those pages appear.
2nd pages are those that load in ajax in the first kind.I mean their links are in 1st kind pages and after click on that ,the related 2nd kind page loads in ajax.
I know how to create 1st kind pages and the 2nd one itself.but I have know a little about ajax.
can you give me a simple example ?
briefly an ajax page that loads with a link.I need view ,model and controller pages.
Thanks


Ajax load - El Forum - 02-27-2014

[eluser]Unknown[/eluser]
Hi

I solve this by including the following in the 1st page, this will call your controller/method and display whatever is returned in the target div.

$('#buttonid').on('click', function(event)
{

$.ajax(
{
type: "POST",
url: "<?php echo base_url();?>index.php/controller/method",
data: {variable:value1,variable2:value2},
success: function(data, status)
{

$('#targetdiv').html(data);



}
}
);
}
);