Catch fatal error while loading dynamically loaded xml file with loadpano

  • Hi!

    We are using dynamically loaded xml files when using the loadpano functionality. Sometimes these xml files don't exist, which means loadpano will display a "FATAL ERROR" with 204 code.

    I'd like to catch this error, which doesn't crash the player. Is something like this possible?

    What would happen if our backend would return a 404 error instead? It would be great if we could use the onloaderror event somehow...

  • Now we've tried with 404 instead, but it keeps giving a "FATAL ERROR" message.

    Is there anyway to avoid this?


    A 404 page, or any non XML structure will probably always cause a "FATAL ERROR" when you try and load it directly into KRpano. To avoid this you should either provide some type of valid XML data when the file does not exist or there could be a mechanism that if the XML file is valid/exists and based on that calls loadpano.

    There are two ways to go about it, the first is to use a server-side loader with something like PHP, which would check if the XML is valid and pass it on or generate valid XML with an error report when it doesn't.

    The other is a bit easier to implement in this case and it uses the javascript XML dom to check for a 404. That would look a bit like this :

    I haven't tested it so perhaps it needs some tweaking, but this should basically work.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!