p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Web Programming > JavaScript > Javascript
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 15th, 2005, 06:45 PM
Registered User
 
Join Date: Jun 2005
Location: , , .
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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 16th, 2005, 11:21 AM
nzakas's Avatar
Wrox Author
Points: 647, Level: 9
Points: 647, Level: 9 Points: 647, Level: 9 Points: 647, Level: 9
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 192
Thanks: 0
Thanked 2 Times in 2 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/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old June 16th, 2005, 09:08 PM
Registered User
 
Join Date: Jun 2005
Location: , , .
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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old June 18th, 2005, 06:52 AM
joefawcett's Avatar
Wrox Author
Points: 8,994, Level: 40
Points: 8,994, Level: 40 Points: 8,994, Level: 40 Points: 8,994, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,922
Thanks: 0
Thanked 13 Times in 12 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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old June 20th, 2005, 09:04 PM
Registered User
 
Join Date: Jun 2005
Location: , , .
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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old June 22nd, 2005, 02:15 PM
Registered User
 
Join Date: Jun 2005
Location: , , .
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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 05:49 AM



All times are GMT -4. The time now is 07:35 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc