0
を使用してJavascriptからPHPに変数を渡す私はその後、場所私のコードの上部にワードプレスのプラグイン
近くの呼び出しの上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);
}
});
}
機能GoogleマップのAPIを実装して、私の機能を
<script type="text/javascript" src="//code.jquery.com/jquery-1.12.0.min.js"></script>
を持っています
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!");
}
});
}
と私のscript.phpには私が
<?php
$uid = isset($_POST['userID']);
?>
しかし、成功アラートには何らかの理由が表示されません。
申し訳ありませんが、まだ成功していないという警告は、あなたが与えたコードを追加した後にポップアップします。私が間違っていることが他に何かありますか? –
geocodeAddress()が呼び出されていますか? – milkcup
ジオコードボタンがクリックされると直ちに呼び出されます –