Code: Select all
<script type="text/javascript"><!--
$('select[name=\'product_id\']').on('change', function() {
$.ajax({
url: 'index.php?route=information/product/profunc&product_id=' + this.value,
dataType: 'json',
beforeSend: function() {
$('select[name=\'product_id\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>');
},
complete: function() {
$('.fa-spin').remove();
},
success: function(json) {
html = json['code'];
$('input [name=\'productcode\']').html(html);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$('select[name=\'product_id\']').trigger('change');
//--></script>
Code: Select all
public function profunc() {
$json = array();
$this->load->model('localisation/product');
$product_info = $this->model_localisation_product->getPro($this->request->get['product_id']);
if ($product_info) {
$json = array(
'product_id' => $product_info ['product_info'],
'reserved1_id' => $product_info ['reserved1_id'],
'name' => $product_info ['name'],
'code' => $product_info ['code'],
'status' => $product_info ['status']
);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}