현재 왼쪽 열에 트리 뷰를 표시하고 있습니다. 사용자가 노드를 선택하면 오른쪽 열 #details를 ajax 호출의 응답으로로드합니다. 이것은 잘 작동합니다.MVC 3 면도기의 마스터 - 디테일 샘플 코드 (자세한 내용은 Ajax 사용) - 제 2 부
이제 아약스를 통해 오른쪽 열 #details를 제출하고 싶습니다. 나는 서버에 다시 게시물을 캡처 할 수 있지만 문자열을 반환하면 #details 섹션에 '성공적으로 저장된'문자열이있는 전체 페이지가로드됩니다.
문자열 'saved successfully'가 정말로 필요합니다. 오른쪽 열의 div 요소에 배치됩니다.
이것은 다시 (나는 제 Ajax 응답을 반환 할) 다른 AJAX 반응을 수행하여 Ajax 응답이다.
이것이 가능합니까?
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
그렇지 않으면 :
내 편집 양식을 사용하면 Ajax.*
헬퍼를 사용하려는 경우 당신은 당신의 페이지에 다음 스크립트를 포함했는지 확인하십시오 다음
@using (Ajax.BeginForm("Edit", new AjaxOptions { UpdateTargetId = "#results" })) {
@Html.ValidationSummary(true)
if (Model != null) {
<fieldset>
<legend>Code</legend>
@Html.HiddenFor(model => model.CodeID)
<div class="editor-label">
@Html.LabelFor(model => model.Description)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Note)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Note)
@Html.ValidationMessageFor(model => model.Note)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.DateModified)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.DateModified)
@Html.ValidationMessageFor(model => model.DateModified)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.TopicID)
</div>
<div class="editor-field">
@Html.DropDownListFor(model => model.TopicID, (SelectList)ViewData["Topics"], "Select")
@Html.ValidationMessageFor(model => model.TopicID)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Special)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Special)
@Html.ValidationMessageFor(model => model.Special)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Html)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Html)
@Html.ValidationMessageFor(model => model.Html)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
<div id="results">
Status
</div>
가와, 그럼 난 [이 그것입니다] 생각 (http://stackoverflow.com/q/5532568/75500). – Shimmy