client code
send.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="http://127.0.0.1/jquery-3.3.1.js"></script>
<script>
function Ajax(){
$.get("receive.php",
{user:$("-sharpuser").val(),comment:$("-sharpcomment").val()},
function(data){
$("-sharptarget").append(data);
});
};
</script>
user:<input id="user" type="text">
comment<textarea id="comment" name="" cols="20" rows="2"></textarea>
<input type="button" value="Ajax submit" onclick="Ajax()">
<div id="target"></div>
</body>
</html>
receive.php
<?php
header("Content-type:text/html;charset=utf-8");
$user = $_GET["user"];
$comment = $_GET["comment"];
echo "<h3>user:" . $user . "</h3>";
echo "comment:" . $comment . "
";
?>
after the client sends data, I open 127.0.0.1/receive.php
and the result is
user:
comment:
Why not:
user:john
comment:1234