Ничего не получается с библиотекой.
Что делал:
1. Создал контроллер "catalog/controller/calculators/main.php"
<?php
class ControllerCalculatorsMain extends Controller {
public function start() {
$this->load->library('calculators/testcalc');
$json = array();
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
?>
2. Создал библиотеку с классом: "system/library/calculators/testcalc.php"
<?php
class Testcalc {
public function calculate($data) {
return $data;
}
}
?>
3. Если в представлении происходит событие ajax-ом делается post запрос в контроллер:
function recalc() {
msg="quantity="+document.getElementById("input-quantity").value+"&"+($('#calculator').serialize());
$.ajax({
url: 'index.php?route=calculators/main/start',
type: 'post',
data: msg,
dataType: 'json',
beforeSend: function() {
},
success: function(json) {
alert ('SUCCESS');
if (json['error']) {
alert (json['error']);
}
if (json['success']) {
document.getElementById("input-quantity").value = json['quantity'];
document.getElementById("price").innerHTML = json['total']+' руб.<small> ('+json['price'] + ' р./шт)</small>';
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert ('ERROR');
}
});
}
Проверяем.
В итоге ошибка 'ERROR'
Теперь комментируем эту строку в контроллере : "$this->load->library('calculators/testcalc');"
Опять запускаем, всё ОК, сообщение: 'SUCCESS'
Вывод - не подключается библиотека. По какой причине понять не могу.
Пробовал подключать системные библиотеки - то же самое.
Помогите, пожалуйста, уже запарился пробовать разные варианты.