An der Spitze von meinem Code ich habePassing Variable von Javascript PHP Wordpress-Plugin
<script type="text/javascript" src="//code.jquery.com/jquery-1.12.0.min.js"></script>
Dann die meine Funktionen implementieren api google maps
function geocodeAddress(geocoder, resultsMap) {
var lat = '';
var lng = '';
var address = document.getElementById('address').value;
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK') {
lat = results[0].geometry.location.lat();
lng = results[0].geometry.location.lng();
alert(lng + ' ' +lat);
nearLocation();
resultsMap.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: resultsMap,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
Funktion über Anrufe in der Nähe Lage
function nearLocation()
{
alert("hi");
var userID = "Hello";
//alert($(this).attr('id'));
$.ajax({
type: "POST",
url: 'script.php',
data: "userID=" + userID,
success: function(data)
{
alert("success!");
}
});
}
und in meiner script.php habe ich
aber Erfolgsalarm zeigt keinen Grund warum?
Sorry, aber immer noch keine Erfolgsalarm erscheint, nachdem ich den Code, den Sie gaben, hinzufügen. Ich verstehe jedoch, was Sie meinten. Kann ich sonst noch etwas falsch machen? –
Wird geocodeAddress() jemals aufgerufen? – milkcup
Sobald der Geocode-Button angeklickt wird, wird er aufgerufen –