Solved

Javascript JQuery Code Error

Posted on 2011-03-14
2
2,512 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

635 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