0
function showpos(position){
lat=position.coords.latitude
lon=position.coords.longitude
var enderDe = (+lat+',' +lon);
How do I save the variable enderDe
in my database?!
0
function showpos(position){
lat=position.coords.latitude
lon=position.coords.longitude
var enderDe = (+lat+',' +lon);
How do I save the variable enderDe
in my database?!
0
According to your answers, using jQuery.post, you can try the following:
function showpos(position) {
lat=position.coords.latitude;
lon=position.coords.longitude;
var latlon = JSON.stringify({lat:lat,lon:lon});
saveLatLon(latlon);
}
function saveLatLon(pos) {
$.post('url/do/teu/php.php',pos,function(data) {
console.log(data); // aqui voce trata data como quiser
}
}
on the php side you’ll have to do anything like
if (isset($_POST['lat']) && isset($_POST['lon'])) {
// chamada ao MySQL e tratamento de dados aqui
}
To not use jQuery, you need to use the Xmlhttprequest to make an AJAX call to your PHP.
Browser other questions tagged javascript mysql ajax
You are not signed in. Login or sign up in order to post.
What is the language used on the server?
– bfavaretto
If the language used is PHP, use ajax
– Igor
php,... but wanted to save without the user having to press a button,.. otherwise by post it wouldn’t work
– user3500281
Ajax has nothing to do with user action clicking friend button.
– Guilherme Nascimento
sorry dude, but if I’m asking here, it’s already assumed that I don’t understand about,...
– user3500281
You use
jQuery
? If yes, you can make a very easy resolution. If not, you can adapt to Vanilla.– Rafael Almeida
I do not use, until then only php and html, now arrived at the moment I need to learn,..
– user3500281