0
Hello, I’m trying to pass a simple parameter to a PHP server using AJAX and I’m not getting this parameter in PHP. The error returned is that the index "parameter" of the GET method is not defined. It follows below the codes
ajax function :
function AJAX(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST','./functions/adicionafoto.php', true);
var data = "parametro=OK"
xmlhttp.send(data);
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
console.log(xmlhttp.responseText)
}
}
};
}
PHP server code :
<?php
session_start();
$parametro = $_GET['parametro'];
echo $parametro;
?>
Error returned: Undefined index: parameter
Does anyone have any idea why this is happening?
It worked, thank you!
– Átila Bernardo