Why can't $GET receive the data submitted by the AJAX. Get method?

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

May.22,2021

The second parameter in

hehe $.get is callback. To use $.get, you must put it in the parameter of url. It is recommended to use $.ajax

.
$.ajax({
    url:'receive.php',
    data:{user:$("-sharpuser").val(),comment:$("-sharpcomment").val()},
    type:"get",
    success:function(data){
        $("-sharptarget").append(data);
    }
});

OK

clipboard.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bfcf-2c2e1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bfcf-2c2e1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?