2
ジオロケーションデータが準備完了またはAJAXリクエストの準備が整う前に、新しいDIV IDへのアニメーションとロードが発生することがあるJQTouchに問題があります。JQTouchとジオロケーションとPHPへの動的AJAXリクエストの処理
私はpageAnimationStartを試してみました(それも良いかどうかは分かりませんが)。プロセス内でコードが完全に壊れています(エラーはなく、ただ実行されません)。
アニメーションを開始する前に、イベントリスナーがAJAXとジオロケーションが動作するのを待つように、以下のコードで自分の関数を設定する方法に関する提案はありますか?
function locationList(clicked_id) {
navigator.geolocation.getCurrentPosition(
function(position) {
$('#location-list').bind('pageAnimationStart', function(event, info){
if (info.direction == 'in')
$.ajax({
beforeSend: function() {
$('#location-list').html('<div class="ajax-load"><img src="img/ajax-loader.gif" /></a>');},
url: 'search.php',
type: 'GET',
data: 'id='+clicked_id+'&action=geolocation&latitude='+position.coords.latitude+'&longitude='+position.coords.longitude,
success: function(msg) {
$('#location-list').html(msg);
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert('Error submitting request.');
}
});
}, /* position */
function() {
$('#location-list').html('<div class="toolbar"><h1>GPS Error</h1><a class="back" href="#home">Home</a></div><div class="scroll"><ul class="rounded"><li><p>To take advantage of this app you need the GPS capability of your phone turned on. Please check whether this is turned on or else the app will not work</p></li></ul></div>');
} /* no position so failure */
);/* bind */
}/* position */
); /* navigator.geo */
}