I am using Codeigniter with Zurb Foundation framewrk. i am tryin to load data in reveal box(fancy popup) using AJAX.. The trick is, i am not loading just the inner html content, but the HTML itself..I mean, i want the function in controller to return the php file to ajax calling function whose contents will be displayed in popup.. My code is
Ajax function call
function ajaxfunct() {
$.ajax({
type: "POST",
url: "welcome/test",
data: { name: "Jigar", location: "jain" }
}).done(function( html ) {
$("#tagUser").append(html);
});
}
My Controller Code is
public function test() {
$data['name'] = $_POST['name'];
$data['location'] = $_POST['location'];
$this->load->view('index', $data);
echo 'WHAT SHUD I ECHO HERE ?'
}
I know the last 2 lines of my Controller code is wrong..I just dont know how to fetch a php file from views folder, process it and pass it to ajax as a pre-processed html(string).
I am not looking for entire code..just a reference to some function or online tutorials will be great..
thanx
You already do fetch a PHP file from your views folder in your Controller.
The line
Loads the /application/views/index.php file and processes it with data from the $data array.
So for Your AJAX call you could make a different view file than index.php like test.php that contain the proper HTML for the AJAX and call it with the line
And skip the ECHO part…