I have a very simple task, I have to render Partial Views on the main Page so that the whole Page is not loaded every time I click a link rather just that particular div
or section
.
Check this out:
When you click a link at the header on the above website, it only loads the particular section not the whole page.
I have tried many solutions on the Internet but I could not make it work.
Solutions I have tried:
Since I can not explain all of them, I am only going to ask about this one:
After reading a lot of tutorials I got the dummy Project to work but its not working in a Project that my team is working on:
내 Home
이름에 PartialView를 추가했습니다 Partial
.
Home
컨트롤러에 메서드를 추가했습니다 .
public PartialViewResult Test()
{
return PartialView();
}
내 버튼을 추가했습니다 Index
.
<input type="submit" id="clik" />
내 JavaScript :
<script type="text/javascript">
$('#clik').click(function () {
$("#s").load("/Home/Test");
});
</script>
다음 참조를 추가했습니다.
<script src="../../Scripts/jquery.unobtrusive-ajax.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
제출을 클릭하기 전 스크린 샷
제출을 클릭 한 후의 스크린 샷
이것은 내 더미 프로젝트에서는 잘 작동하지만 팀이 작업중인 프로젝트에서는 제대로 작동하지 않습니다. 위에서 설명한 것과 똑같은 단계에 따라이를 구현하려고하면 페이지를 검사하는 동안 다음 오류가 발생합니다 Google Chrome Developer Tools
.
GET http://localhost/Employees/Test 404 (Not Found)
jquery-1.7.2.min.js:4
send jquery-1.7.2.min.js:4
f.extend.ajax jquery-1.7.2.min.js:4
f.fn.extend.load jquery-1.7.2.min.js:4
(anonymous function) Employees:278
f.event.dispatch jquery-1.7.2.min.js:3
h.handle.i jquery-1.7.2.min.js:3
저는 ASP .Net MVC의 초보자이고 ASP .Net MVC 4를 사용하고 있습니다.
더 간단하게하려면 :
UpdateTargetId
는 AS id
의 div
당신이 당신의 부분보기를 표시 할 위치를.이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다