用戶這種形式的上進入地址,然後在驗證地址,並運行此:訪問AJAX/jquery的返回的數據,並將其放置到形成場
$('#verify').click(function() {
var address = $('input[name=address]');
var city = $('input[name=city]');
var state = $('input[name=state]');
var zip = $('input[name=zip]');
var country = $('select[name=country]');
//organize the data for the call
var data = 'address=' + address.val() + '&city=' + city.val() + '&state=' + state.val() + '&zip=' + zip.val() + '&country=' + country.val();
//start the ajax
$.ajax({
url: "process.php",
type: "GET",
data: data,
cache: false,
success: function (html) {
//alert (html);
if (html!='error') {
//show the pin long and lat form
$('.form2').fadeIn('slow');
} else alert('Error: Your location cannot be found');
}
});
//cancel the submit button default behaviours
return false;
});
process.php需要的數據,並驗證地址是否存在,然後將緯度和經度發回爲「經度,緯度」。如何獲取這些數據並將其放置在表單字段中,該表單字段顯示該位置是否已找到(form2 div中的表單字段)。非常感謝。
如果它們是2個需要更新的字段呢?一個是緯度,一個是經度?再次感謝! – Sergio 2011-04-08 23:51:32