2012-03-24 12 views
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 */ 

    } 

答えて

0

I「は、完全な:」上のページを変更しようとする:ので、データを取得し、ページを埋める「成功」の代わりにの「成功:」その後に移行を開始する「完全:」

詳細情報:http://api.jquery.com/jQuery.ajax/

関連する問題