Trying to send a variable with ajax to php.
The js:
var test1 = "test"
$.ajax({
type : "POST",
url : "getid.php",
data: {test1 : test1},
success: function() {
console.log("message sent!");
}
});
"message sent!" comes up in the console
The php:
<?php
$test1 = $_POST['test1'];
echo $test1;
?>
Error message:
Notice: Undefined index: test1...
I don't really see what i have done wrong here... Any ideas?
UPDATE* when doing `
$.ajax({
type : "POST",
url : "getid.php",
data: {"test1" : test1},
success: function(msg) {
console.log("message sent!");
console.log(msg);
}
});
This logs "test"
Still getting the same error in the php though..