我有這個頁面,在這裏我選擇從下拉列表中的項目,以及一個Ajax調用沿着選定的參數傳遞到一個新的動作在我的控制器,就像這樣:爲什麼我的操作不能返回視圖?
function select(e) {
var unit = $("#unitList").data("kendoDropDownList").value();
var url = '@Url.Content("~/Reports/UnitRunReport/")';
$.ajax({
url: url,
data: { selectedUnit: unit },
type: 'GET',
dataType: 'json',
success: function (data) {
//
},
error: function() {
//
}
});
}
這裏是我的控制器:
public class ReportsController : BaseController
{
public ReportsViewModel Model { get; set; }
//
// GET: /Reports/
public ActionResult Index()
{
Model = new ReportsViewModel
{
Units = UnitClient.GetListOfUnits(true, "")
};
return View(Model);
}
[HttpGet]
public ActionResult UnitRunReport(string selectedUnit)
{
var unit = Convert.ToInt32(selectedUnit);
Model = new ReportsViewModel
{
UnitRuns = RunClient.GetRunListForUnit(unit)
};
return View(Model);
}
}
我必須爲兩個操作(Index和UnitRunReport)分開視圖。調試時,它將正確的參數傳遞給UnitRunReport操作,並在return View(Model)
語句中移動。有人能解釋爲什麼我沒有重定向到Index頁面的新UnitRunReport視圖嗎?