Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Off Topic
    4. Json Datei mit HTML Datei vebinden

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Json Datei mit HTML Datei vebinden

    This topic has been deleted. Only users with topic management privileges can see it.
    • Abhara Huq
      Abhara Huq last edited by Negalein

      Hallo!
      Ich habe ein Problem. Meine HTML Datei sieht wie folgt aus:

      <!DOCTYPE html>
      <html>
      <head>
          <title>JSON Script</title>
      </head>
      <body>
      <script>
              // JSON-Datei laden
              fetch('C:\Users\HUQ3FE\Documents\HTML Übungen\json1.json')
                  .then(response => response.json()) // JSON-Inhalt als Objekt lesen
                  .then(data => {
                      // Code aus JSON ausführen
                      eval(data.code);
                  })
                  .catch(error => console.error('Fehler beim Laden der JSON-Datei:', error));
          </script>
          <p id="demo"></p>
      
          
      </body>
      </html>
      

      Meine Json Datei:

      {
        "code": "document.getElementById('demo').innerHTML = 5 + 6;"
      }
      
      
      

      Eigentlich sollte, wenn ich die HTML datei öffne im Browser, die Zahl 11 erscheinen. Aber das klappt nicht. Chat GPT hat leider auch nicht geholfen... Vielleicht weiß hier jemand mehr
      Danke 🙂

      OliverIO 1 Reply Last reply Reply Quote 0
      • OliverIO
        OliverIO @Abhara Huq last edited by OliverIO

        @abhara-huq

        Ein Browser kann nicht auf einen lokalen Pfad zugreifen.
        Dazu wird ein Webserver benötigt der die Datei dann übermittelt. Dann kann auch fetch verwendet werden
        Aber dann mit http/https protokoll

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate

        983
        Online

        31.7k
        Users

        79.7k
        Topics

        1.3m
        Posts

        2
        2
        82
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo