2012-02-19 9 views
1

私はそれはAJAXを使用してXMLフィードからいくつかの場所を表示するコードのこのビットを持っています二度。私がもう一度やり直すと、それは3回表示されます。AJAXページの更新をダブル結果

+0

empty()あなたのAjax呼び出しの戻り値を何???私たちに例を挙げてください。 –

答えて

1

は、あなたが更新されたセットを追加する前に#destinationListから、以前のAJAX呼び出しのデータempty()する必要があります。

$.ajax({ 
    type: "GET", 
    url: "testxml.xml", 
    dataType: "xml", 
    success: function(xml) { 
     $("#destinationList").empty(); // This will clear out all the previously appended 'a' elements 
     $(xml).find("Country[Name='"+localStorage.ArrivalCountry+"']").find('Destination').each(function() { 
      var destinationName = $(this).attr('Name'); 
      $('<a class="listItem" href="#" id="'+destinationName+'">'+destinationName+x+'<div class="arrow"></div></a>').appendTo('#destinationList'); 
     }); 
    } 
}); 

詳しい情報について

+0

彼はページをリフレッシュすると書いています。したがって、Webアプリケーションのステートレスであるため、その必要はありません。もし私が彼を正しく理解すれば。 – gdoron

+0

ありがとうございます。問題を解決しました:D – Andrei

関連する問題