can't get xmlhttprequest working on nodemcu

Posted on
  • Hi, forgive me for my bad english.

    I'm using a nodemcu devkit 0.9 with espruino v1.89. When I add these lines, my board seems to crash. I can't get the prompt and i have to disconnect en reconnect the board to usb, then make a reset. If i remove these lines, everything is fine.

    '<script>'+
                'function postForm(e) {'+
                  'e.preventDefault();'+
                  'var mode = document.getElementById("mode").value;'+­
                  'var hostname = document.getElementById("hostname").valu­e;'+
                  'var ssid = document.getElementById("wifiSSID").valu­e;'+
                  'var pass = document.getElementById("wifiPass").valu­e;'+
                  'var data = { "mode": mode, "hostname": hostname, "ssid": ssid, "pass": pass };'+
                  'var xmlhttp = new XMLHttpRequest();'+
                  'xmlhttp.open("POST", "/save");'+
                  'xmlhttp.setRequestHeader("Content-Type"­, "application/json;charset=UTF-8");'+
                  'xmlhttp.send(JSON.stringify(data);'+
                '}'+
    

    This is the memory without these lines:
    ={ "free": 1332, "usage": 368, "total": 1700, "history": 383 }

    So it's not a problem with memory limit. It seems to be a problem with xmlhttp.open, xmlhttp.setRequestHeader and xmlhttp.send. The problem appears just when I add the 3 lines. Any idea ??

  • file converter solved my problem ....

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

can't get xmlhttprequest working on nodemcu

Posted by Avatar for azer @azer

Actions