title: Trouble getting XML data to show on HTML using jQuery
body: <p>I'm working on my new PC builds website and I have trouble getting XML tag with specific attribute to show up in my HTML <code>&lt;p&gt;</code> element. My XML looks like this:</p>
  
  <pre><code>&lt;?xml version="2016.6" encoding="UTF-8"?&gt;
  &lt;parts&gt;
    ...
    &lt;HDDs&gt;
      &lt;hdd id="1"&gt;
        &lt;name&gt;DiskOne&lt;/name&gt;
        &lt;price&gt;50&lt;/price&gt;
      &lt;/hdd&gt;
      &lt;hdd id="2"&gt;
        &lt;name&gt;DiskTwo&lt;/name&gt;
        &lt;price&gt;40&lt;/price&gt;
      &lt;/hdd&gt;
    &lt;/HDDs&gt;
    ...
  &lt;/parts&gt;
  </code></pre>
  
  <p>I want to find tag <code>&lt;hdd&gt;</code> with attribute <code>id="2"</code> in above XML and show its child's <code>name</code> content in HTML <code>&lt;p&gt;</code> element, which has the <code>id="test-xml"</code>. I used this jQuery code to get data from XML and show that in <code>&lt;p&gt;</code>:</p>
  
  <pre><code>  function loadHDDs(name)
    {
      $.ajax({
        type: "GET",
        url: 'data/parts.xml',
        dataType: "xml",
        success: parseHDDsXml
      });
    }
    function parseHDDsXml(xml, name)
    {
      $(xml).find('hdd[id="2"]').each(function(){
        var name;
  
        name = $(this).children('name').text();
  
        $("#test-xml").text(name);
      });
    }
  </code></pre>
  
  <p>I found the code in another website and I don't really know, what do I need to write in brackets after <code>loadHDDs</code>, so I wrote <code>name</code>. I don't know how to cleanly make the script execute when the page is loaded, so I added <code>onload="loadHDDs();"</code> to the <code>&lt;body&gt;</code> element on my page. I use Google Chrome debugger to find errors. When I tested my page locally, on my computer, debugger, of course showed that <code>XMLHttpRequest cannot load</code>. I uploaded my project to the server and I receive no errors in the Chrome debugger at all, but the text in <code>&lt;p&gt;</code> element doesn't change to the XML text. What am I doing wrong? Maybe something is wrong with my script? Or XML document? Maybe I just don't know to execute jQuery script and <code>onload</code> just doesn't work? Please, help me! I'm a beginner in jQuery and Javascript, so I kindly ask you to show me the easiest and most understandable way of fixing the problem.</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT: I don't have enough reputation to comment. I added <code>error</code> function to my Ajax as Nayeri suggested and now I get an error that <code>loadHDDs</code> is not defined. I don't understand that. We can clearly see <code>function loadHDDs(name)</code> in my script. I have checked the spelling a hundred times.</p>