> function performLocationSearch() { let kw = document.getElementById('locSearchInput').value; let tbody = document.getElementById('locationSearchResults'); tbody.innerHTML = 'Searching...'; let url = (typeof baseUrl !== 'undefined' ? baseUrl : (window.location.origin + '/flystarcourier/public')) + '/admin/bookings/geocodeSearch'; if (window.location.href.indexOf('/branch/') !== -1) { url = url.replace('/admin/', '/branch/'); } fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Requested-With': 'XMLHttpRequest' }, body: 'keyword=' + encodeURIComponent(kw) }) .then(r => r.json()) .then(res => { if(res.status === 'success' && res.data && res.data.length > 0) { let html = ''; res.data.forEach(item => { let code = item.code || item.name.substring(0,3).toUpperCase(); let fullAddr = (item.full_address || item.name).replace(/'/g, "\\'"); html += `
${item.name}
${fullAddr}
${item.pincode || code} `; }); tbody.innerHTML = html; } else { tbody.innerHTML = 'No locations found.'; } }) .catch(e => { tbody.innerHTML = 'Error searching.'; }); }