I'm trying to test this out with my code, and it's grabbing it as undefined.
I'm posting this because my reputation isn't at 50. I'm trying to test what this person was saying: https://stackoverflow.com/a/24310507/11852136 .
As summarized, it clearly echos it out, but when I try grabbing the value, it comes back as undefined.
file bin/A.php:
<?php
$fname = $_POST["fname"];
$SomethingElse = '';
$TestGrab = 'MEHOY MENOY!';
echo "Hi ".$fname."!";
echo nl2br ("\n");
?>
<input type="hidden" id="Error" value="<?php echo $TestGrab ?>" />
file B.js:
$.ajax({ type:'POST',
url: 'location/bin/A.php',
data:{fname:fname},
success: function(data){
console.log(data);
var grabbing = $("#Error").val();
console.log("Error: " + grabbing);
}
});
What I expected it to do was for console.log("Error: " + grabbing);
to output to the console Error: MEHOY MENOY!
, but instead it gives me Error: undefined
. Can I have some instructional help?