Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/boxberry.delivery/ |
Upload File : |
function handleDatalist(input) { const dataListId = input.id + '-datalist'; let dataList = document.getElementById(dataListId); if (!dataList) { dataList = document.createElement('datalist'); dataList.id = dataListId; input.setAttribute('list', dataListId); input.parentNode.appendChild(dataList); } input.addEventListener('input', function () { const searchTerm = this.value; dataList.innerHTML = ''; if (searchTerm.length >= 2) { fetch('/bitrix/services/main/ajax.php?action=boxberry:delivery.api.service.getPointsForParcels&searchTerm=' + encodeURIComponent(searchTerm) + '&sessid=' + BX.bitrix_sessid()) .then(response => { if (!response.ok) { throw new Error(BX.message('ERROR_RESPONSE')); } return response.json(); }) .then(data => { console.log(data); if (data.status === 'success') { data.data.forEach(name => { const option = document.createElement('option'); option.value = name; dataList.appendChild(option); }); } else if (data.errors[0].message === BX.message('POINTS_UPDATE_IN_PROCESS')) { alert(data.errors[0].message); } else { console.log(data.errors[0].message); } }) .catch(error => { console.error(BX.message('ERROR_RESPONSE') + ':', error); }); } }); }