3

I have been trying to pull in the names of the albums from picasa using the jquery xml parser. However when I use the "https://picasaweb.google.com" link the function doesn't work. Any clues as to what I am doing wrong?

 <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>
Goldy234
  • 83
  • 1
  • 1
  • 8

3 Answers3

3

For those interested below is the corrected code

<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>
Goldy234
  • 83
  • 1
  • 1
  • 8
2

you can do the cross domain requests (if the server supports it) by

setting crossDomain:true (added in jquery 1.5)

and/or

by setting dataType:'jsonp'

or else you can create a server side proxy to which you can do the ajax request that proxy will in turn get data from the web service and retyrn the response

see this answer for creating and getting data back in PHP jQuery.ajax() parsererror

Community
  • 1
  • 1
Rafay
  • 30,950
  • 5
  • 68
  • 101
1

You are trying to access data on a different origin without using JSONP and the browser is putting security walls in front of you.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335