Не работает скрипт.
Почему не инициализируются объекты типа o_CoinAcceptor в методе m_FillFrom ? Разработчик браузера показывает ошибку - Uncaught TypeError: Cannot set property 'Active' of undefined, так для всех элементов o_CoinAcceptor
<script> /** * Created by Andreu on 03.03.14. */ function ConfigObject() { //create objectConfigForm this.o_Form = function objectConfigForm() { //appTimingConfig this.PayTimeOut = null; this.ShowMessageTimeOut = null; this.TimeAutoReport = null; //equipmentConfig this.o_CoinAcceptor = { Active: null, Port: null, Baud: null, NoWokrAnError: null, RetriesCount: null, DeviceName: null } } this.m_FillFrom = function () { //appTimingConfig this.o_Form.PayTimeOut = document.configForm.PayTimeOut.value; this.o_Form.ShowMessageTimeOut = document.configForm.ShowMessageTimeOut.value; this.o_Form.TimeAutoReport = document.configForm.TimeAutoReport.value; //equipmentConfig this.o_Form.o_CoinAcceptor.Active = document.configForm.CoinAcceptorActive.value; this.o_Form.o_CoinAcceptor.Port = document.configForm.CoinAcceptorPort.value; this.o_Form.o_CoinAcceptor.Baud = document.configForm.CoinAcceptorBaud.value; this.o_Form.o_CoinAcceptor.NoWokrAnError = document.configForm.CoinAcceptorNoWokrAnError.valu e; this.o_Form.o_CoinAcceptor.RetriesCount = document.configForm.CoinAcceptorRetriesCount.value ; this.o_Form.o_CoinAcceptor.DeviceName = document.configForm.CoinAcceptorDeviceName.value; } this.m_Save = function () { if (confirm("Сохранить тариф?")) { this.m_FillFrom(); alert("m_FillFrom!"); $.ajax({ type: "POST", dataType: "json", //url: url, что здесь нужно? contentType: 'application/json; charset=utf-8', data: JSON.stringify(this.m_FillFrom()), success: alert("success"), error: alert("error") }) }else (alert("Saving canceled.")) } } var config = new ConfigObject(); </script> |
Часовой пояс GMT +3, время: 01:55. |