Hi guys,
i have a problem with sending some data with an simple http form.
HTML Code:
> <html> > <head><meta charset="utf-8"/></head> > <body><h2>Konfiguration</h2> <form action="#" method="post"> > <div class="container"> > <label for="test"><b>TEST</b></label><input type="text" placeholder="Enter text" name="test" required> > </form> > </body> > </html>
JS on Espruino
var data = ""; req.on('data', function(d) { data += d; }); req.on('end', function() { postData = {}; console.log(data); data.split("&").forEach(function(el) { var els = el.split("="); postData[els[0]] = decodeURIComponent(els[1]); });
If I enter the following to the form: "PLUS++++LEER OK" The browser send: "PLUS%2B%2B%2B%2BLEER+++++OK"
On espruino: test=PLUS%2B%2B%2B%2BLEER+++++OK Now I call the "decodeURIComponent" but the result is "PLUS++++LEER+++++OK"
I would expect the following: "PLUS++++LEER OK" https://www.w3schools.com/tags/att_form_enctype.asp
You have the same behaviour? The blank issnt decoded correctly.
@iwae started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi guys,
i have a problem with sending some data with an simple http form.
HTML Code:
JS on Espruino
If I enter the following to the form: "PLUS++++LEER OK"
The browser send: "PLUS%2B%2B%2B%2BLEER+++++OK"
On espruino: test=PLUS%2B%2B%2B%2BLEER+++++OK
Now I call the "decodeURIComponent" but the result is
"PLUS++++LEER+++++OK"
I would expect the following: "PLUS++++LEER OK"
https://www.w3schools.com/tags/att_form_enctype.asp
You have the same behaviour? The blank issnt decoded correctly.