おそらくajaxの経験が浅いために、奇妙な問題と戦っています。何らかの理由で、ActionResult が PartialView を返す前に、Ajax 関数がエラー警告ダイアログを起動します。
私のajax関数がエラーをスローする理由、または私が間違っていることさえ、誰でも見つけることができますか?
私のJquery
function GetSalesLinesByArea(e) {
var areaId = treeView().getItemValue(e.item);
$('#HiddenAreaId').val(areaId);
var url = '/SalesLine/IndexPartial/';
$.ajax({
type: "GET",
dataType: "html",
url: url,
data: { areaNodeId: areaId },
success: function (data) {
$('#HuntingGrid').html(data);
alert("success!");
},
error: function () {
alert("error!");
}
});
}
私の見解 Index.cshtml
@using Telerik.Web.Mvc.UI
@using Veidivefur.Model.Entity
@model Veidivefur.ViewModels.SalesLineViewModel
@{
ViewBag.Title = "Hlunnindi";
}
<div id="HuntingGrid">
@{ Html.RenderPartial("IndexPartial"); }
</div>
私のパーシャルビュー IndexPartial.cshtml
@using Telerik.Web.Mvc.UI
@model Veidivefur.ViewModels.SalesLineViewModel
<div>
@(Html.Telerik().Grid(Model.SalesLines)
.Name("Grid")
//More Telerik stuff
</div>
*コントローラーの私のインデックスActionResult *
public ActionResult Index()
{
List<CombinedSalesLine> combinedSalesLines =
GenerateSalesLines(_salesLineModel.FindAllSalesLinesLargerThanToday(0));
return View(new SalesLineViewModel(combinedSalesLines));
}
*コントローラーの私のIndexPartial ActionResult *
public ActionResult IndexPartial(string areaNodeId)
{
int areaNodeInt = Convert.ToInt32(areaNodeId);
List<SalesLine> saleslines = areaNodeInt == 0 ? _salesLineModel.FindAllSalesLinesLargerThanToday(0)
: _salesLineModel.FindAllSalesLinesLargerThanToday(areaNodeInt);
List<CombinedSalesLine> combinedSalesLines = GenerateSalesLines(saleslines);
return PartialView("IndexPartial", new SalesLineViewModel(combinedSalesLines));
}