0
我正在使用表單將一些值發佈到控制器。發佈日期時間值
這裏是js代碼;
$.ajax({
type: "POST",
url: "GetReports",
data: {
MacId: $("#select-definition").val(),
StartDate: $("#input-start-date").val(),
EndDate: $("#input-end-date").val(),
},
dataType: "JSON"
})
.done(function (result) {
console.log(result);
})
.fail(function() {
})
.always(function (result) {
console.log(result);
});
});
這裏是HTML;
<form id="form-reports" action="" >
<div class="col-lg-3">
<select class="selectpicker" name="MacId" id="select-definition" required></select>
</div>
<div class='col-sm-3'>
<div class="form-group">
<div class='input-group date'>
<input type='datetime' id='input-start-date' name="StartDate" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class='col-sm-3'>
<div class="form-group">
<div class='input-group date'>
<input type='datetime' id='input-end-date' name="EndDate" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="col-lg-2">
<button class="form-control" type="button" id="button-submit">Done</button>
</div>
</form>
這裏是控制器(我張貼表格);
[HttpPost]
public string GetReports(string MacId, DateTime StartDate, DateTime EndDate)
是錯誤的;
POST http://localhost:55616/Home/GetReports 500(內部服務器錯誤)
我無法找出錯誤和解決方案,
我想輸入的值傳遞給控制器
請注意,我使用MVC C#Web應用程序。
在此先感謝