这是我从部分视图中获取数据的第一次练习,但我不知道我的代码中出了什么问题。我无法得到任何数据。
在我的主视图文件夹中,我创建了一个名为Fault_statPartial
的部分视图,在我的主视图中,我将其称为如下所示:
<div>
@{ Html.RenderPartial("Fault_statPartial"); }
</div>
在我的局部视图中我有一个按钮,当我点击它时,它应该返回数据。这是部分视图代码:
@model string
<html>
<head>
<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
</head>
<body>
<script src="@Url.Content("~/Scripts/KndoTst/jquery.min.js")"></script>
<script src="@Url.Content("~/Scripts/KndoTst/kendo.all.min.js")"></script>
<script src="@Url.Content("~/Scripts/KndoTst/jquery.maskedinput.js")"></script>
@section Scripts{
<script src="@Url.Content("~/Scripts/KndoTst/jquery.min.js")"></script>
<script src="@Url.Content("~/Scripts/KndoTst/kendo.all.min.js")"></script>
<script src="@Url.Content("~/Scripts/KndoTst/jquery.maskedinput.js")"></script>
<button type="button" class="buttonForMonthlydailyYearly" id="faultstat" >FaultStat</button>
<script type="text/javascript">
var turbineName = [];
var finalResultYear = [];
var data = [];
var data_wind = [];
var finalResultWind = [];
//DropDownList
var drp = "s";
var topTenResultOfMonth = null;
var topTenResultOfYear = null;
var topTenResultOfDay = null;
var selcted;
var tmp;
var tmpString;
$("#faultstat").click(function (e) {
debugger;
tmp = $("#multiselect").val();
tmpString = tmp.toString();
$.ajax({
dataType: "json",
type: "POST",
url: "@Url.Action("faultStatstics","Ranking")",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ "id": tmpString }),
success: function (result) {
debugger;
var productionResult = result.sumOfDay[0].m_energy_prod;
var productionMonthresult = result.sumOfMonth;
var productionofYear = result.sumofyear;
// debugger;
$("#production").empty();
$("#production").append(productionResult);
$("#monthProduction").empty();
$("#monthProduction").append(productionMonthresult);
$("#yearProduction").empty();
$("#yearProduction").append(productionofYear);
}
});
});
</script>
}
</body>
</html>