|
|
 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

June 15th, 2005, 06:45 PM
|
|
Registered User
|
|
Join Date: Jun 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
xml feed with javascript
Is there anyway to read an xml page that is located on a different server with javascript?
|

June 16th, 2005, 11:21 AM
|
 |
Wrox Author
|
|
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 192
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Doing this would require the use of a server-side proxy to get around the cross-domain security restrictions in JavaScript.
For instance, set up a CGI script on your server that calls the XML file and returns the contents, then have JavaScript call that CGI script.
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
|

June 16th, 2005, 09:08 PM
|
|
Registered User
|
|
Join Date: Jun 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Would it be possible to use frames to solve this? For example, you would have a page with two frames. One page would be the xml parsing page, while the other page would be set to http://www.someXMLfeed.com?keyword=. This frame would load the xml you need. Is there a way to read the contents of this frame with the other frame?
|

June 18th, 2005, 06:52 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,922
Thanks: 0
Thanked 13 Times in 12 Posts
|
|
No, cross domain restrictions would still apply although if the page were a trusted site and security restrictions were reduced it may work. For this you'd really have to be in an intranet situation.
It would be a severe security risk if web pages could do this. They could load bank logon pages into a secondary frame and read the cookies from the bank site as well as other personal info.
You will have to use some sort of server side proxy.
--
Joe ( Microsoft MVP - XML)
|

June 20th, 2005, 09:04 PM
|
|
Registered User
|
|
Join Date: Jun 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I ended up using an aspx page that does a HTTPWebRequest to a site that pulls the xml I'm looking for. Since its on the same server the javascript can access it just fine. Everything works fine with IE, but it does not work in firefox. I think is due to fact that IE waits for the aspx page to pull the feed why firefox does not. I am using XmlDom.Load(the aspx page?search term=). Do you have any suggestions? Thank you.
|

June 22nd, 2005, 02:15 PM
|
|
Registered User
|
|
Join Date: Jun 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Nevermind, I have fixed the problem by adding <%response.ContentType="text/XML"%> to the page that pulls the feed. Thank you.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |