I’ve made many different attempts at this so my mistake must be really obvious, my knowledge of JQuery isn’t great but I’ve even tried examples straight from the internet, but I can’t seem to get it, all I want to do is pass the variable “myLatlng” to a PHP file and echo the result of the PHP file on callback, currently the PHP file consists of:
$data=$_POST['coord'];
echo $data;
The JavaScript is:
$.post("/includes/eventgrab.php", { "coord": myLatlng },
function(data) {
alert("Data Loaded: " + data);
}, "text"
);
I have used firebug and myLatlng does hold a value. Please help
The below should work fine assuming you have the
eventgrab.phpat the correct location (use firebug to see whether it is making a call nicely to that page) and you have a proper value in themyLatlngvariable.