php怎么发送“成功”俩个字到前端,前端如何读取并console.log打印

php代码


<?php
header("Content-type:text/html;charset=UTF-8");
$data=json_decode($_POST['data']);
$repon=array("成功");
$json=urldecode(json_encode($repon));
echo $json;
?>

前段js代码

// 监听来自content-script的消息
chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse){        
    console.log("收到来自content-script的消息:");
      pageinfo=request.msg;
      console.log(request.msg);
    var rep=$.ajax({
          type:"post",
         url:"http://127.0.0.1/mysqlhelper.php",
         dateType:"json",
         async:true,
         date:{date:pageinfo},
             error: function(request) {
                             console.log("Connection error");
                         },
                success: function(repon) {
                             console.log(JSON.stringify(repon));
                         }
         });
    
});

就发送一个字符串,怎么一直转换数据类型
php:

$data= $_POST['date']
echo $data

js:


$.ajax({
    type:"post",
    url:"http://127.0.0.1/mysqlhelper.php",
    async:true,
    data:{date:pageinfo},
    success:function(res){
        console.log(res)
    }
})