제출 버튼이있는 아약스 양식이 있지만 제출 버튼을 클릭하면 404 페이지를 찾을 수없는 오류가 발생합니다. 내보기의Ajax에서 404 오류가 발생하지만 URL이 올바른 경우
부 :
ajaxOptions 변수는이 같이 정의된다@using (Ajax.BeginForm("Index", "Maps", null, ajaxOptions, new { @class = "form-search" }))
{
...
...
<button type="submit" class="btn">Search</button>
}
:
var ajaxOptions = new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "filter-results",
LoadingElementId = "filter-loading",
LoadingElementDuration = 2000,
OnFailure = "showAjaxError",
Url = Url.Action("Index")
};
이 지금처럼 내 브라우저 (크롬)에서 렌더링 :
<form action="/Maps" class="form-search" data-ajax="true" data-ajax-failure="showAjaxError" data-ajax-loading="#filter-loading" data-ajax-loading-duration="2000" data-ajax-mode="replace" data-ajax-update="#filter-results" data-ajax-url="/Maps" id="form0" method="post"> <div class="well well-small">
<div class="input-append">
<input type="text" class="span3">
<button type="submit" class="btn">Search</button>
</div>
<div class="input-prepend pull-right">
<button type="submit" class="btn">Items Per Page</button>
<input type="number" name="ItemsPerPage" class="span1" value="10">
</div>
</div>
</form>
404 오류 :
Requested URL: /Maps
내 브라우저에이 붙여 넣을 수 있습니다 그것은 작동합니다
http://localhost:7374/Maps
을 나는 파일이 자바 스크립트 우측 참조하는 것 같아 - 나는이 볼 수있는 페이지 소스에서 상대 :
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.0/jquery-ui.min.js"></script>
을 내 Web.config 내가 가진이 :
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
또 다른 부끄러운 실수는 작업 메서드에서 액세스 한정자를 잊어 버리는 것입니다. 내 코드를 디버깅하는 데 시간을 할애하고 "public"으로 액션 메소드에 플래그를 지정하지 않았다는 것을 깨달았습니다. – Luther