我遇到有关geolocation.getCurrentPosition()的问题
我有以下代码:
$(document).on('click', '#find_pickupStoresNearMe_button', function (e) {
e.preventDefault();
var formAction = $(this).parents('form').attr('action');
$('#locationForSearch').val('');
navigator.geolocation.getCurrentPosition(function (position) {
console.log(position);
ACC.pickupinstore.locationSearchSubmit('', formAction, position.coords.latitude, position.coords.longitude);
}, function (error) {
console.log("An error occurred... The error code and message are: " + error.code + "/" + error.message);
});
});
问题是由于位置未定义,函数直接跳入函数(错误)。我在不同商店的不同文件夹中具有相同的代码,并且html结构相同,并且可以很好地检索City我请求搜索输入。
HTML代码:
<form id="command" name="pickupInStoreForm" class="searchPOSForm clearfix" action="/store/store-pickup/pointOfServices"
method="POST">
<table>
<tbody>
<tr>
<td>
<div class="control-group left">
<div class="controls">
<input type="text" name="locationQuery" id="locationForSearch" class="left" placeholder="Adauga Oras">
</div>
</div>
</td>
<td>
<button type="button" class="" id="pickupstore_search_button">Gaseste magazin</button>
</td>
<td>
<button type="button" class="" id="find_pickupStoresNearMe_button">Localizeaza pozitia pe harta</button>
</td>
</tr>
</tbody>
</table>
<div>
我是javascript和jQuery的新手,很抱歉,如果该问题陈述不明确或需要其他信息,请告诉我。对于在哪里寻找该问题的任何帮助,将不胜感激。