Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-08-2011, 09:11 AM   PM User | #1
paulinho
New to the CF scene

 
Join Date: Mar 2011
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
paulinho is an unknown quantity at this point
fetch xml using ajax

Hi!
I am sending a getCapabilities- request "http://atlas.gc.ca/cgi-bin/atlaswms_en?VERSION=1.1.1&REQUEST=Getcapabilities&SERVICE=wms" that results in a xml-file, I want to parse this file to get the layers in a rollist.

The problem is that i don't know hot to get the requested xml-file, I don't know how or where in the code to put the url. I am using httpXMLrequest but i do not get it to work..
I am using javascript
please help me!

Paul

Last edited by paulinho; 03-08-2011 at 02:44 PM..
paulinho is offline   Reply With Quote
Old 03-08-2011, 02:59 PM   PM User | #2
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
If your httpXMLrequest originates from another domain (not atlas.gc.ca), this violates the same origin policy and will not work. You would have to fetch it on the server side and pass it to your Javascript from there. If the request does originate from atlas.gc.ca, you would have to post some code, so we can see why it's not working.
venegal is offline   Reply With Quote
Users who have thanked venegal for this post:
paulinho (03-09-2011)
Old 03-09-2011, 03:49 PM   PM User | #3
paulinho
New to the CF scene

 
Join Date: Mar 2011
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
paulinho is an unknown quantity at this point
Okey, I'm setting up a website from my own pc: in the javascript I would like a function that via a httpXMLrequest saves the getcapabilties xml, so I can parse it and use the values in different fields in the website. I don't know where to put the URL and which url to use. can tou help me with the javascript and give me an example of code that would save the xml from atlas.gc.ca?
paulinho is offline   Reply With Quote
Old 03-09-2011, 04:31 PM   PM User | #4
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
Well, you can't do that. It violates the same-origin policy. Also, you can't use Javascript to save files. But you can fetch the file on the server side (i.e. with PHP, using simplexml_load_file or something) and use it however you like; either directly use the data to build the HTML, or pass it off to Javascript as JSON.

Also, what's
Quote:
I don't know where to put the URL and which url to use.
supposed to mean? How would I know which URL you need to use for whatever you are doing? What's wrong with the one in your original post?
venegal is offline   Reply With Quote
Old 03-09-2011, 08:22 PM   PM User | #5
paulinho
New to the CF scene

 
Join Date: Mar 2011
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
paulinho is an unknown quantity at this point
I ment the Url in the first post, and if I should use the whole file, never mind, I also saw I was a little bit unclear there. Thanks for your help and I will try to solve it with your tips.
paulinho is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:50 AM.


Advertisement
Log in to turn off these ads.