external server XML

0

I am generating an html file that brings data from an xml but if it is not inside my server it does not show it and I need to bring it from an external server since it will be managed from the outside. What is the error? the file is noticias.xml that I need that comes from an external server.

Thanks

What I do is a button that has onclick="loadXMLDoc () and in a table with id=" table "that I list them.

The problem is probably in the following script:


function loadXMLDoc() {
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      myFunction(this);
    }
  };
  xmlhttp.open("GET", "noticias.xml", true);
  xmlhttp.send();
}
function myFunction(xml) {
  var i;
  var xmlDoc = xml.responseXML;
  var table="NoticiaFoto";
  var x = xmlDoc.getElementsByTagName("CD");
  for (i = 0; i " +
    x[i].getElementsByTagName("TITULO")[0].childNodes[0].nodeValue +
    "" +
    x[i].getElementsByTagName("FOTO")[0].childNodes[0].nodeValue +
    "";
  }
  document.getElementById("demo").innerHTML = table;
}

    
asked by Jonatan Ezequiel Caudo 23.05.2017 в 20:31
source

2 answers

0

I think you're having a CORS problem. that is, the server from where you want to obtain the xml does not allow requests from other domains, it could not be controlled from the client code, it should be configured on the server.

Do you have an error message?

You can review this topic

  

link

    
answered by 23.05.2017 в 23:42
0

XMLHttpRequest can not load link . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access.

    
answered by 24.05.2017 в 03:41