Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Javascript JQuery Code Error

Posted on 2011-03-14
2
2,349 Views
Last Modified: 2013-11-18
Hi all,

I am trying out some code but I cannot get it to conect to the feed...I just get the error but not sure why or how to fix it.

Anyone got any ideas please?

Code is attached below.

Thanks

<html>
<head>

<script type="text/javascript"
 src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/
jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $.ajax({
                type: "GET",
                url: "http://feeds.bbci.co.uk/news/rss.xml",
                dataType: "xml",
                success: parseXml,
                error: errorMsg
        });

        function parseXml(xml)
        {
                $('#output').empty();
                $(xml).find("entry").each(function()
                {
                        var title = $(this).find('title').text();
                        var pubDate = $(this).find('link').text();
                        var summary = $(this).find('description').text();
                        var thumb = $(this).find('[nodeName=media:thumbnail]').attr('url');
                        var listItem = $('<li><img src=' + thumb + ' /><br/>' + title +
pubDate + '<br/>' + summary + '</li>');
                        $("#output").append(listItem);
                });
        }

        function errorMsg() {
                $("#output").append("error getting xml feed");
        }

  }); <!-- end jq ready -->
</script>

</head>
<body>
<h2>xml test</h2>
<div style="border:1px solid #555">
<div id="foo" style="background-color: #ccc"></div>
        <ul id="output">loading ...</ul>
</div>
</body>
</html>

Open in new window

0
Comment
Question by:error77
  • 2
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35134042
You're not allowed to do a cross domain ajax call:
you page hosting by www.apple.com can't get data on a page at www.microsoft.com

more info and workaround here for example :
http://jimbojw.com/wiki/index.php?title=Introduction_to_Cross-Domain_Ajax
http://en.wikipedia.org/wiki/Same_origin_policy
http://usejquery.com/posts/9/the-jquery-cross-domain-ajax-guide
http://jquery-howto.blogspot.com/2009/04/cross-domain-ajax-querying-with-jquery.html

Just google for : ajax call cross domain


note cross protocol are not allowed to :
https://www.apple.com can't get a page on http://www.apple.com
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35134270
you page hosting by -> your page hosted by

Thanks for the points! Have a nice week!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question