How to load different views in one div that situated in home page on button click using ajax,jquery,codeigniter

363 Views Asked by At

I have a page like home now what I want is if I click a button or link like a menu a corresponding view must load in that div in the home page. On every button click the views are must change inside the div without refreshing the entire page.

I know this can be done with ajax and jquery.

1

There are 1 best solutions below

0
On

on click event of button call a javascript method, collect information which affect different views, send ajax request in a controller with post data, according to data, load a view like

$res = $this->load->view('myview1')

Remember, ajax request should not be of "json" type.

Ajax request will send a string, take this string in a javascript var. now in javascript

$('#div_id').html(res);