87,907
社区成员
发帖
与我相关
我的任务
分享
var man = new Man;
//实例更改属性
man.set({name:"andy"});
//save会执行Backbone.sync 若model定义了sync则不会执行服务器请求
man.save({success:function(model,response){
console.log(model.toJSON().name);
console.log("ok");
}},{error:function(model,response){
console.log(model.toJSON().name);
console.log("err");
}});
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json; charset=utf-8');
//不能通过$_POST获取。因为$_POST['paramName'] 只能接收Content-Type: application/x-www-form-urlencoded提交的数据
$man = json_decode(file_get_contents("php://input"));
$array=array($man->name,$man->author,$man->price,$man->des);
file_put_contents("data.txt",$man->name);
echo file_get_contents("php://input");
?>