【发布时间】:2013-06-01 17:00:37
【问题描述】:
我在使用 $.getJSON 的方法时遇到问题。这很简单,看起来像这样: 取 ID из DropDownlList CategoryId
<div id="partial" class="editor-label">
@* @Html.Partial("");*@
</div>
$(document).ready(function () {
$('#CategoryId').change(function () {
$.getJSON('/Publication/AjaxAction/' + this.value, {},
function (html) {
$("#partial").html(html);
alert("go");
});
});
});
发送
public ActionResult AjaxAction(int Id)
{
if (Request.IsAjaxRequest())
{
if (Id== 1)
{
ViewBag.SourceTypeId = new SelectList(db.SourceTypes, "Id", "Title");
ViewBag.CityId = new SelectList(db.Cities, "Id", "Title");
return Partial("_CreateStatya");
}
}
return PartialView();
}
您能告诉我如何返回 Partial in 吗??
<div id="partial" class="editor-label">
@* @Html.Partial("");*@
</div>
【问题讨论】:
-
$(document).ready(function () { $('#CategoryId').change(function () { $.get('@Url.Action("AjaxAction","Publication" )',{id:$('#CategoryId').val()}, 函数 (html) { $("#partial").html(html); alert("go"); },'html') ; }); });