ajax json php post 方法
2024-10-21 22:55:47
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;
最新文章
- 分享我基于NPOI+ExcelReport实现的导入与导出EXCEL类库:ExcelUtility (续篇)
- 深入浅出设计模式——建造者模式(Builder Pattern)
- BZOJ4155 : [Ipsc2015]Humble Captains
- thinkphp隐藏中url的index.php
- java学习容器
- make menuconfig 是一个目录。停止 错误解决
- 在android.app.Application中定义全局变量
- jQuery ajax - ajax() 方法
- 【GitHub-SwipeMenuListView】针对ListView item的側滑菜单
- Stm32高级定时器(四)
- Android 开发笔记 “调用WebService”
- jquery append 动态添加的元素绑定事件on
- 微调数据库表结构,30 分钟搞定 WordPress 数据库查询缓慢问题
- 服务注册中心之ZooKeeper系列(二) 实现一个简单微服务之间调用的例子
- 【Zabbix】Zabbix Server自动发现
- 洛谷P4774 屠龙勇士
- The Little Prince-12/08
- [phy]在uboot阶段失能phy芯片
- Python 匿名参数
- js-传送file