can anyone help me with this simple code. I get this error:
"Notice: Undefined index: name in C:\xampp\htdocs\test.php on line 2
The id you have entered is "
I would also like to know how to pass multiple values in the ajax statement like:
data: {name: "john", country: "UK"}
Retrieve it on Server side and finally post it back to the initial page.
Client side:
<script>
$(document).ready(function(){
$("#btn").click(function(){
$.ajax({
type: "POST",
url: "test.php",
data: {name: "John"}
})
.done(function() {
$("#output").load("test.php");
});
});
});
</script>
<form>
<input type="button" value="Test" id="btn" />
</form>
<div id="output"> </div>
Server side:
<?php
$student =(string) $_POST['name'];
//$student = isset($_POST['name'])?$_POST['name']:'err';
$message = "Name: ".$student;
echo ($message);
?>