i am trying to simply get a variable from javascript to php, but php doesnt receive my variable - instead it receives the whole page-code.
Here is my test-page:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$("#button").click(function() {
var test = "Hallo Welt";
$.ajax({
url: "ajax.php",
type: "post",
data: {
test: test
},
success: function (response) {
alert(response);
},
error: function(jqXHR, textStatus, errorThrown) {
alert(textStatus, errorThrown);
}
});
});
});
</script>
</head>
<body>
<form>
<input type="button" id="button" value="Test" style="width:200x">
</form>
<?php
if(isset($_POST["test"])) {
echo $_POST["test"];
}
?>
</body>
</html>
Does anyone have an hint?
greetings