Solved

Javascript JQuery Code Error

Posted on 2011-03-14
2
2,429 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
[X]
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
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to count occurrences of each item in an array.

737 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