2011-07-11 6 views
3

jquery xmlパーサーを使用して、picasaからアルバムの名前を取得しようとしています。しかし、「https://picasaweb.google.com」リンクを使用すると機能が動作しません。私が間違っていることの手がかりは?Jquery XML Parse URLの問題

<script> 
     $(document).ready(function() 
    { 
     $.ajax({ 
     type: "GET", 
     url: "https://picasaweb.google.com/data/feed/api/user/userID?kind=album&access=visible", 
     dataType: "xml", 
     success: parseXml 
     }); 
    }); 

    function parseXml(xml) 
    { 
     $(xml).find('entry').each(function() 
     { 
     $("#output").append($(this).find('title').text() + "<br />"); 
     }); 
    } 
    </script> 


    <div id="output"></div> 

答えて

2

(サーバーがサポートしている場合)あなたはdataType:'jsonp'

を設定することにより、(jQueryの1.5で追加)

および/または

を​​を設定

により、クロスドメイン要求を行うことができますかそれ以外の場合は、プロキシがWebサービスからデータを取得し、応答をretyrnするajaxリクエストを行うことができるサーバー側のプロキシを作成することができます

以下興味のある人のために戻ってPHP でjQuery.ajax() parsererror

1

あなたはJSONPを使用せずにdifferent origin上のデータにアクセスしようとしているとブラウザがあなたの前にセキュリティの壁を入れています。

2

のデータを作成し、取得するため、この答えは修正されたコード

<script> 
    $(document).ready(function() 
{ 
    $.ajax({ 
    type: 'GET', 
    url: 'https://picasaweb.google.com/data/feed/api/user/userID?kind=album&access=visible', 
    crossDomain: true, 
    dataType: 'jsonp', 
    success: parseXml 
    }); 
}); 

function parseXml(xml) 
{ 
    $(xml).find('entry').each(function() 
    { 
    $("#output").append($(this).find('title').text() + "<br />"); 
    }); 
} 
</script> 
で見ます