pafke
pafke

Reputation: 1

Xml to HTML5 with javascript

I thought this was a quite common question, but for some reason I can't find the answer anywhere.

I want to read out xml data and put it in my html5 app. The xml file is hosted on a different server. So I've allready got an HTML5 site with layout, I've got the location of my xml file, how do I implement specific data in to my html?

Upvotes: 0

Views: 590

Answers (2)

Quentin
Quentin

Reputation: 943220

In most browsers, you can't for security reasons. In some newer browsers you can use Cross-Origin Resource Sharing providing the data provider cooperates.

Otherwise you need to make the data available on the same server as the application, or have the data provided in JSON-P format.

Upvotes: 2

SLaks
SLaks

Reputation: 887365

For security reasons, you cannot use Javascript to read content from a different domain.

You need to write a server-side script on your domain to forward the XML.
You can then use normal AJAX to create the page.

Upvotes: 0

Related Questions