0
我在尋找一種方法來從輸入到一個PHP變量插入範圍的數據,這是怎麼了我的代碼看:插入從範圍數據PHP變量與Ajax請求
HTML:
<div class="form-group" ng-app="Filter" ng-controller="InsertFilter">
<form>
<label for="limit">Limit:</label>
<input type="text" class="form-control" id="limit" name="limit" ng-model="limit">
<label for="page">Page:</label>
<input type="text" class="form-control" id="page" name="page" ng-model="page">
<label for="from">From:</label>
<input type="date" class="form-control" id="from" name="from" ng-model="from">
<label for="to">To:</label>
<input type="date" class="form-control" id="to" name="to" ng-model="to">
<button type="submit" class="btn btn-default" style="margin-top: 15px;">Show Report</button>
</form>
Ajax請求在角:
var FilterApp = angular.module('Filter', []);
FilterApp.controller('InsertFilter', function($scope, $http) {
$http.post("/api/data-dashboard.php").then(function(response){
$scope.limit = /* ??? */;
});
});
數據dashboard.php:
if (empty($_POST["from"])) {
$from = date('Y-m-d');
} else {
$from = $_POST["from"];
}
if (empty($_POST["to"])){
$week = time() + (7 * 24 * 60 * 60);
$to = date('Y-m-d', $week);
} else {
$to = $_POST["to"];
}
if (empty($_POST["page"])) {
$page = 1;
} else {
$page = $_POST["page"];
}
if (empty($_POST["limit"])) {
$limit = 10;
} else {
$page = $_POST["page"];
}
感謝您的所有好評。
*我應該將輸入轉換爲json格式嗎?