Slim Framework と PUT リクエストに問題があります。ボタンがクリックされたときに有効期限を更新する小さなjQueryスクリプトがあります。
$("#expiry-button").click(function(event) {
event.preventDefault();
$.ajax({
url: 'http://www.domain.com/expiry/38/',
dataType: 'json',
type: 'PUT',
contentType: 'application/json',
data: {aid:'38'},
success: function(){
var text = "Time updated";
$('#expiry').text(text).addClass("ok");
},
error: function(data) {
var text = "Something went wrong!";
$('#expiry').text(text).addClass("error");
}
});
});
私はいつも「何かがおかしい!」と言います。
Slimを構成したindex.phpには、これがあります
$app->put('/expiry/:aid/', function($aid) use($app, $adverts) {
$id = $app->request()->put($aid);
$adverts->expand_ad_time($id["aid"]);
});
var_dump($id)
私がNULLを取得した場合
応答ヘッダーは次のようになります。
Status Code: 200
Pragma: no-cache
Date: Wed, 08 May 2013 12:04:16 GMT
Content-Encoding: gzip
Server: Apache/2.2.16 (Debian)
X-Powered-By: PHP/5.3.3-7+squeeze15
Vary: Accept-Encoding
Content-Type: text/html; charset=utf-8
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Transfer-Encoding: chunked
Connection: Keep-Alive
Keep-Alive: timeout=15, max=100
Expires: Thu, 19 Nov 1981 08:52:00 GMT
およびリクエストボディ
Request Url: http://www.domain.com/expiry/38/
Request Method: PUT
Status Code: 200
Params: {
"aid": "38"
}
したがって、コミュニケーションはありますが、望ましい結果ではありません。私は何を間違っていますか?