Jump to content

Read in xml file

Recommended Posts

I want to setup a javascript page on my website where I have a xml file that has a name comment and gps coordinates. The user types in the name and and it searches the xml file and spits out the comment and coordinates.  My main question is where can I upload file for my page to search and how( what path do I use to read it in)

Link to comment
  • Replies 2
  • Views 661
  • Created
  • Last Reply

So this is my code if I use the path  "/s/cd_catalog.xml" or  "cd_catalog.xml" I get a status of 404

If I use  "s/cd_catalog.xml" I get a status of 0 which doesn't make sense

 

<button type="button" onclick="loadXMLDoc()">Get my CD collection</button>
<br><br>
<table id="demo"></table>

<script>
function loadXMLDoc() 
{
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function()
  {
  var table=this.status;
  document.getElementById("demo").innerHTML = table;
  };
  xmlhttp.open("GET", "s/cd_catalog.xml", true);
  xmlhttp.send();
}

</script>Untitled.thumb.png.aabf91a7d51891537e12b215c7685c85.png

1Untitled.png

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.