[eluser]riwakawd[/eluser]
Thanks to Tim Brownlaw who helped me on Skype about this issue thought me a lot.
Problem is now fixed.
On view We added
Code:
[removed]
console.log('Jquery is working');
$('select[name="config_template"]').on('change', function () {
var template_name;
template_name = encodeURIComponent(this.value);
$.ajax({
type: 'POST',
dataType: 'json',
url: '<?php echo base_url('admin/setting/template');?>' + '/',
data: { config_template: template_name
},
complete: function () {
$('.fa-spin').remove();
},
success: function (data) {
$('.fa-spin').remove();
$('#template').attr('src', data.image);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
})
[removed]
On controller added
Code:
public function template() {
$this->load->helper('html');
if (file_exists(FCPATH . 'image/templates/' . $this->configs->get('config_template') . '.png') == FALSE) {
$img = base_url('image/no_image.png');
echo json_encode(array('image'=>$img));
}
else
{
if($this->input->post('config_template') !== FALSE)
{
$img = base_url('image/templates/' . $this->input->post('config_template') . '.png');
echo json_encode(array('image'=>$img));
}
}
}