locked
0x800a139e - JavaScript runtime error: HierarchyRequestError RRS feed

  • Question

  • Right in building my app I have got an error of this

    JavaScript runtime error: HierarchyRequestError

    The code with the error is:

    var link = "<a href=\"/pages/rollercoasters/rollercoaster.html\">" + items[i].querySelector("ID").textContent + "</a>";

    And here the whole javascript in full.

    // home.js
    (function () {
        "use strict";
    
        var app = WinJS.Application;
    
        WinJS.UI.Pages.define("/pages/home/home.html", {
            // This function is called whenever a user navigates to this page. It
            // populates the page elements with the app's data.
            
            ready: function (element, options) {
                // TODO: Initialize the page here.
                WinJS.Utilities.query("a").listen("click", linkClickEventHandler, false);
                loadRollerCoasterFeed();
    
            }
        });
    
        function loadRollerCoasterFeed() {
    
            document.getElementById("rcOutput").innerHTML = "";
            WinJS.xhr({ url: "http://rollercoastermad.com/test/xmldata/rollercoaster.xml" }).then(
                parseRollerCoasterFeed, errorRollerCoasterFeed
                );
        }
    
    
        function parseRollerCoasterFeed(result) {
    
            var outputArea = document.getElementById("rcOutput");
            var xml = result.responseXML;
    
            if (xml) {
                var items = xml.querySelectorAll("rollercoasters > item");
                if (items) {
                    var length = Math.min(10, items.length);
                    for (var i = 0; i < length; i++)
                    {
                        var link = "<a href=\"/pages/rollercoasters/rollercoaster.html\">" + items[i].querySelector("ID").textContent + "</a>";
                        var newLine = document.createElement("br");
                        outputArea.appendChild(link);
                        outputArea.appendChild(newLine);
                    }
                } else {
                    outputArea.innerHTML = "There are no items available at this time";
                }
            } else {
                outputArea.innerHTML =
                    "Unable to retrieve data at this time. Status code: " + statusCode;
            }
        }
    
    
    
        function errorRollerCoasterFeed(result) {
    
            var statusCode = result.status;
            var outputArea = document.getElementById("rcOutput");
            outputArea.innerHTML = "Unable to retrieve data at this time. Status code: " + statusCode;
        }
    
    
        function linkClickEventHandler(eventInfo) {
            eventInfo.preventDefault();
            var link = eventInfo.target;
            WinJS.Navigation.navigate(link.href);
        }
    
        app.start();
    })();
    
    

     

    What that line is supposed to make a link to another page on the app but not working.

    • Edited by Ryan Bowden Monday, October 15, 2012 6:27 PM Put wrong javascript file on.
    Thursday, October 11, 2012 12:34 AM

All replies

  • I don't see anywhere in your sample where the problematic line appears?

    Jeff Sanders (MSFT)

    Monday, October 15, 2012 4:15 PM
    Moderator
  • Hello,

    Sorry put the wrong code up now put the correct code up for you.

    Many Thanks

    Ryan.

    Monday, October 15, 2012 6:40 PM