0

I want to use data from a service provided on another server. I have link to the XML and when i paste the link in my browser. I then get the XML in my browser.

In my page I use the XMLHttpRequest function to call this XML. When i save the XML on my own server as file.xml it works just fine in my webpage.

I use this function:

xmlhttp.open("GET", "file.xml", false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

But when i inserts the link to the external server i get this error:

XMLHttpRequest cannot load http://source.com/XmlFeed.asp?. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mypage.com' is therefore not allowed access.

I have searched the net and understands that this is a blocking so the service is not overloaded.

The provider of the service encurage that users caches the data so there server isnt overloaded. This means that they wont me to make a copy of the XML on my server and update this scheduled?

How can I solve my problem? Is there a problem in my code or how can i update the xml-file on my server with the xml om the provider server?

  • possible duplicate of [XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin](http://stackoverflow.com/questions/3595515/xmlhttprequest-error-origin-null-is-not-allowed-by-access-control-allow-origin) – Jordan Kasper Jan 14 '14 at 20:38

1 Answers1

0

The host of the resource does not permit you to access this resource from your site. As you say, they would like you to host the resource on your site, access your own copy from your web page, and deploy a process on your server to update the cached resource at intelligent intervals. This saves the host from having to provide the resource in support of your application.

aldie_lab
  • 171
  • 3
  • As I tought. How do I set up this update of the file? My server has phpMyadmin on mySQL server. Should I use sql or is there another way to set up this update? Tanx! – user3195539 Jan 14 '14 at 20:32
  • Without knowing too much about your config, I would think you might do this on the Web server. On Linux, you should have the 'wget' command which you can setup to do this automatically. On Windows, you could write a PowerShell script with WebClient.DownloadFile and schedule the task to run when appropriate. – aldie_lab Jan 14 '14 at 21:45
  • It dosent look like I have access to the webserver form my webhoster. I shall ask them tomorow. Tanx! – user3195539 Jan 14 '14 at 22:18