I have a script that get data from two different APIs, but it isn't redirecting in the end of the last request to to the generated link, but it happens only for iPhone users. What am I doning wrong? I can't see it anywhere.
Code:
function calc(){ $('#btCalc').addClass('is-loading'); var req = new XMLHttpRequest(); req.open('GET','https://maps.googleapis.com/maps/api/geocode/json?address='+$('#cdd').val()+'&key=PRIVATE_KEY',false); req.onload = function(){ console.log('carregou!'); var data = JSON.parse(req.responseText); lat = data.results[0].geometry.location.lat; lng = data.results[0].geometry.location.lng; cdN = data.results[0].formatted_address console.log("Cidade natal: "+cdN+" (Lat "+lat+" Long "+lng+")"); uf = data.results[0].address_components[2].short_name; if(uf=="BR"){ uf = data.results[0].address_components[1].short_name; } getGMT(lat, lng); } req.send(); return true; } function getGMT(lat, lng){ var req = new XMLHttpRequest(); var apiUrl = 'https://api.timezonedb.com/v2.1/get-time-zone?key=PRIVATE_KEY&format=json&by=position&lat='+lat+'&lng='+lng; req.open('GET',apiUrl,false); req.onload = function(){ var data = JSON.parse(req.responseText); Utc = (data.gmtOffset/3600); redirectPage(); return true; } req.send(); return true; } function redirectPage(){ try{ if($('#Verao').prop('checked')){ Utc = Utc+1; } nome = $("#nome").val(); dados = "dataNasc="+dataNasc()+"&lat="+lat+"&lng="+lng+"&utc="+Utc+"&cdn="+cdN+"&nome="+nome+"&ayanamsha=CUSTOM_AYANAMSHA"; var urlFinal = 'chart.php?'+dados; alert(urlFinal); $('#redirectPage').attr('href',urlFinal); $('#btCalc').attr('href',urlFinal); $('#redirectPage')[0].click(); $('#redirectPage').show(); $('#btCalc').attr('onclick',''); }catch(e){} }
Comment