Loading remote xml

J

J_Zanetti

Hello everybody,

I would need to load through javascript a remote xml file (a rss feed)
and then use its content to build the page. I am trying to do something
in my local pc and it works fine in IE but in firefox it seems that
remote files cannot be retrieved. So how would it be possilbe to build
a rss ticker entirely in JS working in firefox? The only solution is an
Ajax call??

Thanks very much to anyone who will be able to help me ;)

J_Z
 
M

Martin Honnen

J_Zanetti said:
I would need to load through javascript a remote xml file (a rss feed)
and then use its content to build the page. I am trying to do something
in my local pc and it works fine in IE but in firefox it seems that
remote files cannot be retrieved. So how would it be possilbe to build
a rss ticker entirely in JS working in firefox? The only solution is an
Ajax call??

Your script in a HTML document loaded from e.g. http://example.com/ can
only load XML from http://example.com/ but not from other origins.
 
J

J_Zanetti

Martin Honnen ha scritto:
Your script in a HTML document loaded from e.g. http://example.com/ can
only load XML from http://example.com/ but not from other origins.

Martin, thank you for your answer.
I knew about this, but why does it work on IE?? In IE i created rss
tickers with js and they work on my pc (so i guess also from other
servers).
I got lost on this point :S

Thanks so much!
 
M

Martin Honnen

J_Zanetti said:
I knew about this, but why does it work on IE?? In IE i created rss
tickers with js and they work on my pc (so i guess also from other
servers).
I got lost on this point :S

IE has different security zones each of which can be configured to allow
such access. So it depends on the zone (e.g. file system, intranet zone,
internet zone, trusted sites) and its configuration whether the access
across domains works in IE or not.
 
S

shimmyshack

you will need a proxy script on your server on the same domain as the
ajax call, from which the ajax gets its data.

this gets called by the ajax script.
<?php
header( 'Content_type: text/xml' );
readfile( 'http://remote.domain.com/rss/feed.xml' );
?>

you make the proxy as complicated as it needs to be, so that it
retrieves multiple rss for your XHR calls.

It's not hard to make so there must be a tonne of them out there, they
are even used for flash as well, because of its crossdomain
restrictions.

Also it's a VERY good idea to parse the remote rss scripts first to
remove the possibility of introducing XSS attacks into your html by
directly including the remote scripts. Its my opinion that php or a
server side language would have a much better chance of collecting
feeds which require cookies or other crendentials as well, so a pure JS
implementation would have feature limitations.
 
J

J_Zanetti

shimmyshack ha scritto:
you will need a proxy script on your server on the same domain as the
ajax call, from which the ajax gets its data.

Thank you shimmyshack!

I see this is a nice workout for a serverside application! Looks very
interesting and powerful!
Though, i start to think there's no solution for a client script that
makes the job in Firefox at least...

Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top