-1
I am sending data from a textarea via AJAX to PHP by the POST. method in this textarea contains some square brackets. Well, when the text of the textarea arrives in the POST, it automatically transforms the content of these brackets into another array, in which it should just return a common string. SEE:
let textareaValue = "isso é um teste [e isso também]";
var req = new XMLHttpRequest();
req.open('POST', '../controller/test.php', true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.onreadystatechange = function(){
if (req.readyState != 4 || req.status != 200) return;
console.log(req.responseText);
};
req.send(textareaValue);
RESULT IN PHP:
echo $_POST;
/* output
array(1) {
["isso_é_um_teste_"]=>
array(1) {
["e isso também"]=>
string(0) ""
}
}
*/
sensational! That’s right there. Thanks!
– sigleane