Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2005, 05:45 PM
Registered User
 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default xml feed with javascript

Is there anyway to read an xml page that is located on a different server with javascript?

 
Old June 16th, 2005, 10:21 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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/
 
Old June 16th, 2005, 08:08 PM
Registered User
 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?

 
Old June 18th, 2005, 05:52 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old June 20th, 2005, 08:04 PM
Registered User
 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old June 22nd, 2005, 01:15 PM
Registered User
 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind, I have fixed the problem by adding <%response.ContentType="text/XML"%> to the page that pulls the feed. Thank you.






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET XML Feed Error kwilliams ASP.NET 2.0 Professional 0 February 19th, 2008 05:41 PM
Problems parsing XML Feed in Javascript kwilliams Classic ASP Professional 0 December 18th, 2007 06:33 PM
Problems parsing XML Feed in Javascript kwilliams Javascript 1 November 7th, 2007 05:59 PM
XML news feed sankar XML 1 December 17th, 2003 05:28 AM
XML, XML Schema, JavaScript, ASP cyberjames2003 XML 0 June 4th, 2003 04:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.