Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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.

  • Users who have thanked venegal for this post:

    paulinho (03-09-2011)

  • #3
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?

  • #4
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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
    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?

  • #5
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •