之前一直想看看rest风格的URI的实现,但是对 PUT DELETE方法实在是没有使用过,今天测试了下 记录如下:
?
$('#sidebar ul li a:not(href)').click(function(){
$.ajax({
type: 'DELETE' ,
url: '{echo(url('App_Accounts','rest'))}' ,
data: {username: 'iamsese' ,password: 'sfsfdsfdse'}
});
});
?后台代码:
?
function actionRest(){
// $data = '' ;
// $putdata = fopen("php://input","r");
// while (!feof($putdata))
// {
// $data .= fread($putdata,1024);
// }
// fclose($putdata);
$data = file_get_contents("php://input");
dump($data,$_SERVER['REQUEST_METHOD']);
}
?
不使用
"php://input"
? 就取不到 参数 ,这里记录下 哈哈 基本rest也就能实现了