1、前端

    <script type="text/javascript">
    function LoadData(arg){       

         arg.dept=$("#DeptStr").val();
         arg.clas=$("#ClassStr").val();
         arg.user=$("#UserName").val();
         arg.tno=$("#tNo").text();
         console.log(arg);
         var JsonData = JSON.stringify(arg);
         console.log(JsonData);
        $.ajax({
            type: 'POST',
            url: "AP_TrainSatisfaction_Json.php",
            contentType :"application/json", // 很重要
            data: JsonData,
            dataType: 'json',
            success: function(data){
                console.log(data);
                      // document.getElementById("mark").innerHTML=data["yesNo"];

            }, //end success
           error: function(data){
                console.log(data);
                alert( "error!!!"+data );
            } //end error
        });
    }

    </script>

2 php

header("Content-Type: text/html;charset=utf-8");
header("Content-type:text/json ");

$info = file_get_contents("php://input");
$data=json_decode($info,true);

$XYdata=json_encode($data);
echo $XYdata;

 

posted on 2022-01-15 20:58  木车  阅读(68)  评论(0编辑  收藏  举报