开发者

Xml to HTML5 with javascript

开发者 https://www.devze.com 2023-03-02 17:45 出处:网络
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

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 t开发者_StackOverflowhe location of my xml file, how do I implement specific data in to my html?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消