I need to display an ajax view in a div named showthis, I am able to see the generated view within the console, but how can I get
the view to display within the div "showthis" this is what I have so far.
Thanks in-advance for your assistance.
// Main view setup
foreach($products as $product) : ?>
<div class="acc-item-slot">
<?php echo $product->title; ?>
<?php echo $product->description; ?>
<?php echo $product->sales; ?>
<a href="#" onclick="prev_product(<?php echo $product->campaignID;?>)">Preview</a>
<?php endforeach;
</div>
<div id="showthis"> // I would like to load view below here
<div id="prodview"> // Example of view prodview.php I would like to load
<?php echo $product->title; ?>
<?php echo $product->description; ?>
<?php echo $product->sales; ?>
</div>
</div>
//Controller View setup
public function ajax_edit($id)
{
$this->load->model('Product_model');
$data = $this->Product_model->get_by_id($id);
$this->load->view('prodview', $data);
echo json_encode($data);
}
// Jquery Ajax setup
function prev_product(id){
$.ajax({
type : "POST",
url : "<?php echo site_url('index.php/products/ajax_edit')?>/"+id,
dataType : "JSON",
success: function(data){
$(showthis).load('index.php/products/method', data, true); // tried to load view here but no joy
},
error: function (jqXHR, textStatus, errorThrown)
{
alert('Error get data from ajax');
}
});
}