-1
How do I make the latitude variable work ? I tried this and nothing is appearing! In sucess la inside the latitude variable works, but on the outside it does not want to work, it is empty. How to pass the latitude variable pro php? I have this code below:
$.ajax({
url:'sigilo.com.br/$ip',
type:'get',
dataType:'json',
success:function(res) {
latitude = res.lat;
longitude = res.long;
cidade = res.city;
Pais = res.country
}
});
</script>
<?php
$variavelphp = "<script>document.write(latitude)</script>";
echo $variavelphp;
?>
ai did not understand , :(
– DenyProgramadorBom
@Denyprogramadorbom When PHP loads the page, the variable
latitude
there is no. After loading the page, Ajax will be executed and create the variable, but then that’s it, because PHP already did the part of it that was just load the page.– Sam
Oxenteee javascript does not run while loading with php?
– DenyProgramadorBom
@Denyprogramadorbom Ajax does not return the value together with the page load, only after.
– Sam
@Denyprogramadorbom When the page is loaded, Ajax will still search the page
sigilo.com.br/$ip
the value to define the variablelatitude
.– Sam
But javascript loads together with php right
– DenyProgramadorBom