My Javascript Code is like this :
$(".booking_hotel").click(function(){
var id = this.id;
$.ajax({
type: "POST",
url: base_url + 'hotel_booking/hotel/hotel_booking',
data: id
});
});
Function in my controller is like this :
function hotel_booking()
{
$data = $this->input->post();
$data = array(
'hotel_request' => $data,
);
$this->load->view('hotel_booking/booking_hotel_view',$data);
}
It not successful to load view. But in console firebug(tab html), the view could appear.
How to load view booking_hotel_view when class .booking_hotel clicked?
Thank you
The view from ajax
comes to you as ajax
response. You have to put it in your desired place.
Let you have div with id="my_div"
and you want to show your view in this div
. So your code will be
$(".booking_hotel").click(function(){
var id = this.id;
$.ajax({
type: "POST",
url: base_url + 'hotel_booking/hotel/hotel_booking',
data: id
}).done(function(response){
$('#my_div').html(response);
});
});
try this. It will reload/redirect to you hotel_booking/hotel/hotel_booking
. i.e load your booking_hotel_view
$(".booking_hotel").click(function(){
var id = this.id;
$.ajax({
type: "POST",
url: base_url + 'hotel_booking/hotel/hotel_booking',
data: id
}).done(function(response){
window.location.href = "hotel_booking/hotel/hotel_booking";
});
});
As you doing nothing with your ajax post data you may use as
$(".booking_hotel").click(function(){
window.location.href = "hotel_booking/hotel/hotel_booking";
});