從UI我撥打電話:爲什麼php服務不能獲取變量?
$http.post('services/loadCategory.php', {
'id' :'1',
'type' :'string'
}).then(function(response) {
debugger;
...
}, function(response) {
...
});
在PHP服務,我無法從身體POST請求的變量:
include ("bd.php");
header("Content-type: text/html; charset=windows-1251");
// ----- ----- ----- ----- -----
if (isset($_POST['type'])) {
$type = $_POST['type'];
}
if (isset($_POST['id'])) {
$id = $_POST['id'];
}
//
exit(json_encode(
array('type' => iconv('windows-1251', 'UTF-8', $_POST['type']),
'id' => iconv('windows-1251', 'UTF-8', $_POST['id'])
)));
從服務請求:{ID: '',類型: '' }如何解決這個問題?
'$ _POST'是否有任何內容? (使用'print_r()'來檢查)。 '$ _REQUEST'呢? – Spudley