Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Get Request Webassemply
Forum Updated to NodeBB v4.3 + New Features

Get Request Webassemply

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
2 Posts 1 Posters 200 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • piervalliP Offline
    piervalliP Offline
    piervalli
    wrote on last edited by
    #1

    Hello

    in webassembly i want do a request on my server, if set a static url, it is work, but I need to take host web url.
    window.location is not available , Settings does not works

    function fetchData() {
            var xhr = new XMLHttpRequest();
            var url = window.location.origin + "/data.json";  // Fetch from the same origin
    
            xhr.open("GET", url, true);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === XMLHttpRequest.DONE) {
                    if (xhr.status === 200) {
                        resultArea.text = "Response:\n" + xhr.responseText;
                    } else {
                        resultArea.text = "Error fetching data: " + xhr.status;
                    }
                }
            };
            xhr.send();
        }
    

    Do Have you some idea?

    Thanks
    Pier

    1 Reply Last reply
    0
    • piervalliP Offline
      piervalliP Offline
      piervalli
      wrote on last edited by piervalli
      #2

      There are two fantistic api in c++

      #ifdef __EMSCRIPTEN__
      #include <emscripten.h>  // Required for calling JavaScript
      #endif
      
      #ifdef __EMSCRIPTEN__
          // WebAssembly-specific code
          emscripten_run_script("console.log('Running in WebAssembly');");
      #endif
      #ifdef __EMSCRIPTEN__
          const char* url = emscripten_run_script_string("window.location.href");
          qDebug() << "Current Page URL:" << url;
      #endif
      
      1 Reply Last reply
      0
      • piervalliP piervalli has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved