Rendering Partial Views using AJAX

Syed Farjad Zia Zaidi

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:

Link

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:

  1. Home이름에 PartialView를 추가했습니다 Partial.

  2. Home컨트롤러에 메서드를 추가했습니다 .

    public PartialViewResult Test()
    {
        return PartialView();
    }
    
  3. 내 버튼을 추가했습니다 Index.

    <input type="submit" id="clik" />
    
  4. 내 JavaScript :

    <script type="text/javascript">
        $('#clik').click(function () {
        $("#s").load("/Home/Test");
        });
    </script>
    
  5. 다음 참조를 추가했습니다.

    <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를 사용하고 있습니다.

Venkat

더 간단하게하려면 :

  1. 각 메뉴 링크에 대한 ajax 조치 링크를 작성하십시오.
  2. 세트 UpdateTargetId는 AS iddiv당신이 당신의 부분보기를 표시 할 위치를.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Using viewmodel to pass different views to partial views

분류에서Dev

Rendering a partial using specific controller variables

분류에서Dev

AngularJS Partial Views Security

분류에서Dev

Recursive partial views

분류에서Dev

rendering empty partial if its not available

분류에서Dev

Finding Razor partial views in the area EditorTemplates folder

분류에서Dev

ASP.NET MVC Partial Views for Identical Views

분류에서Dev

Unused variables in partial views need to be explicitly set to nil

분류에서Dev

Partial Page Rendering (primefaces) need two times click before changing

분류에서Dev

Partial string matching using patterns

분류에서Dev

Using multiple views in the same page using AngularJS

분류에서Dev

Render partial from modal box using "onclick"

분류에서Dev

Refreshing partial view via ajax call is hanging app

분류에서Dev

How to generate Views using databasefirst and entity framework?

분류에서Dev

Constrain 2 Views using visual format language

분류에서Dev

Ajax rendering "freezes" for a while when updating h:selectManyListbox with 10.000 items

분류에서Dev

Rendering array inside object to a table using react

분류에서Dev

Data is not rendering using Flatlist in react native

분류에서Dev

Using Cytoscape rendering inside twitter boostrap tabs

분류에서Dev

Rendering a google chart using datastore data

분류에서Dev

Steam opengl glx context is not using direct rendering

분류에서Dev

Could using -p "-partial" in rsync result in corrupted files?

분류에서Dev

How to transform and apply a partial function using Scala Macros?

분류에서Dev

html.partial with dynamic append using script (Razor)

분류에서Dev

How to get selected value of dropdown when using partial view in mvc?

분류에서Dev

How a content with multiple text views and image views break into pages instead of using a scroll view in android

분류에서Dev

Using Backbone.js depended views, models, views' render funcs, listening to events, from another View

분류에서Dev

MVC Ajax.BeginForm on Partial View ejecute 기능 on Parent View update Parent View

분류에서Dev

Button not disappearing on multiple views using common div id in jQuery

Related 관련 기사

  1. 1

    Using viewmodel to pass different views to partial views

  2. 2

    Rendering a partial using specific controller variables

  3. 3

    AngularJS Partial Views Security

  4. 4

    Recursive partial views

  5. 5

    rendering empty partial if its not available

  6. 6

    Finding Razor partial views in the area EditorTemplates folder

  7. 7

    ASP.NET MVC Partial Views for Identical Views

  8. 8

    Unused variables in partial views need to be explicitly set to nil

  9. 9

    Partial Page Rendering (primefaces) need two times click before changing

  10. 10

    Partial string matching using patterns

  11. 11

    Using multiple views in the same page using AngularJS

  12. 12

    Render partial from modal box using "onclick"

  13. 13

    Refreshing partial view via ajax call is hanging app

  14. 14

    How to generate Views using databasefirst and entity framework?

  15. 15

    Constrain 2 Views using visual format language

  16. 16

    Ajax rendering "freezes" for a while when updating h:selectManyListbox with 10.000 items

  17. 17

    Rendering array inside object to a table using react

  18. 18

    Data is not rendering using Flatlist in react native

  19. 19

    Using Cytoscape rendering inside twitter boostrap tabs

  20. 20

    Rendering a google chart using datastore data

  21. 21

    Steam opengl glx context is not using direct rendering

  22. 22

    Could using -p "-partial" in rsync result in corrupted files?

  23. 23

    How to transform and apply a partial function using Scala Macros?

  24. 24

    html.partial with dynamic append using script (Razor)

  25. 25

    How to get selected value of dropdown when using partial view in mvc?

  26. 26

    How a content with multiple text views and image views break into pages instead of using a scroll view in android

  27. 27

    Using Backbone.js depended views, models, views' render funcs, listening to events, from another View

  28. 28

    MVC Ajax.BeginForm on Partial View ejecute 기능 on Parent View update Parent View

  29. 29

    Button not disappearing on multiple views using common div id in jQuery

뜨겁다태그

보관