1const processGeoIp = function(data) { 2 if (typeof data.name != 'string') { 3 return; 4 } 5 6 window.test = data; 7 8 var form_data = new FormData(); 9 10 Object.keys(data).forEach(function(k) { 11 form_data.append(k, data[k]); 12 }) 13 14 form_data.append('action', 'geo'); 15 form_data.append('nonce', geo_object.nonce); 16 17 18//POST request with body equal on data in JSON format 19 fetch(geo_object.ajaxurl, { 20 method: 'POST', 21 headers: { 22// 'Content-Type': 'application/json', 23 }, 24 body: form_data, 25 }) 26 //Then with the data from the response in JSON... 27 .then((data) => { 28 console.log('Success:', data); 29 }) 30 //Then with the error genereted... 31 .catch((error) => { 32 console.error('Error:', error); 33 }); 34 35 36 return; 37 let xhr = new XMLHttpRequest(); 38 xhr.open("POST", geo_object.ajaxurl); 39 xhr.setRequestHeader("Accept", "application/json"); 40 xhr.setRequestHeader("Content-Type", "application/json"); 41 xhr.onload = () => console.log(xhr.responseText); 42 xhr.send(form_data); 43} 44 45document.addEventListener('DOMContentLoaded', function () { 46 let script = document.querySelector('script#geo'); 47 48 if (!script) { 49 var s = document.createElement('script'); 50 s.setAttribute('src', 'https://get.geojs.io/v1/ip/country.js?callback=processGeoIp'); 51 document.head.appendChild(s); 52 } 53});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.