I have used a ajax call to a php function in codeigniter. After getting result I need to show that in a popup in same page. Now I am not able to show as it comes in an array. Below is my codeigniter controller function. I don't think my codes are correct.
public function print_details1() {
$this->isLoggedIn();
$id = $_POST['id'];
$response = $data['notifications'] = $this->file_model->print_view_detail($id);
echo json_encode($response);
}
And ajax request is this
$.ajax({
url: "" + baseurl + "/file/print_details1",
async: false,
type: "POST",
dataType: "html",
cache: false,
data: {id: getvalue},
success: function(response) {
$('#myModal2').modal('show');
}
});
My popup id is myModal2. And I have given below code inside popup.
<?php
foreach ($response as $notification) {
echo $notification->publication_name;
} ?>
Now getting an error while checking using firebug. "Undefined variable: response" and "Invalid argument supplied for foreach()" What is wrong with this?