Ajax UpdateTargedId / Browser doesn't refresh ASP MVC Partial View

user3394944

I Have HTML Page "Index.cshtml"

<div class="container" >
    <div class="row">
        <div class="col-md-6" id="employeeList">
@Html.Partial("IndexPartial");  
        </div>
        <div id="second">
           other div
        </div>
        <button onclick="Increase()">increase</button>
    </div>
</div>

partial view which contains employee table, button which clicked calls JS Script which executes controller method increasing employee age

<script>
    function Increase(id) {
        $.ajax({
            url: 'Main/Increase',
            data: { id: 5 },
            UpdateTargetId:"employeeList",
            success: function () {
                alert('Added');
            }
        });
    }
</script>

I ran firebug and it shows that each button click returns html response with updated employee Table (employee age is updated) but in browser there are still old values until I manually refresh page

Rowan Freeman

You seem a bit confused. Let's go over a few things.

Partial is a built-in method that renders a view to a string (an IHtmlString). This runs once when the page is being constructed.

$.ajax() is a jQuery function. This function (as far as I can recall) does not accept a property called UpdateTargetId. I think you've confused that with the .NET AjaxOptions class which does accept an option called UpdateTargetId.

One way to quickly get things working is to change your success function to take a data argument and then insert the HTML into the div.

success: function (data, textStatus, xhr) { }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ASP.NET MVC 5 - Partial view doesn't work with my AJAX live search

From Dev

Auto refresh in partial view doesn't work

From Dev

Manually refreshing partial view doesn't work after automatic ajax refresh

From Dev

Mvc partial view reload or refresh

From Dev

Not able to refresh the partial view after a form submission from another partial view within it, using ajax in mvc razor

From Dev

FileUpload in Ajax Form in ASP.NET MVC Partial View Not Working

From Dev

Asp.Net MVC Partial View Update with Ajax

From Dev

AJAX with partial view MVC 4 ASP.net C#

From Dev

Ajax (partial view) in ASP.NET MVC 5 is not working - always open just partial view alone

From Dev

Ajax (partial view) in ASP.NET MVC 5 is not working - always open just partial view alone

From Dev

Model binding doesn't work when multiple instances of the same partial view are called dynamically with ajax.actionlink in MVC 5

From Dev

Model binding doesn't work when multiple instances of the same partial view are called dynamically with ajax.actionlink in MVC 5

From Dev

Refresh Partial View Div in MVC 5

From Dev

Asp.net partial view doesn't work

From Dev

Update Partial View Within Partial View Using MVC Ajax

From Dev

Update Partial View Within Partial View Using MVC Ajax

From Dev

MVC Ajax with Dynamic Partial View Creation

From Dev

MVC Ajax returning Partial view but it is not showing

From Dev

AJAX request for a loaded partial view -MVC

From Dev

Returning a partial view with Ajax, MVC 3

From Dev

JQuery Ajax MVC Partial View Not working

From Dev

parserrror SyntaxError: Unexpected token < - Load Partial View using jQuery Ajax in ASP.NET MVC 4

From Dev

asp.net MVC ajax does post back instead of render partial view in my div

From Dev

When to use Partial view in ASP MVC?

From Dev

View doesn't render CSS and Javascript in ASP.NET MVC

From Dev

ASP.Net MVC doesn't map parameters for ajax call

From Dev

ASP.NET MVC with AJAX doesn't work as expected

From Dev

Webpack hot module doesn't refresh the browser

From Dev

Publishing doesn't update the partial [ C#/MVC/ASP.Net ]

Related Related

  1. 1

    ASP.NET MVC 5 - Partial view doesn't work with my AJAX live search

  2. 2

    Auto refresh in partial view doesn't work

  3. 3

    Manually refreshing partial view doesn't work after automatic ajax refresh

  4. 4

    Mvc partial view reload or refresh

  5. 5

    Not able to refresh the partial view after a form submission from another partial view within it, using ajax in mvc razor

  6. 6

    FileUpload in Ajax Form in ASP.NET MVC Partial View Not Working

  7. 7

    Asp.Net MVC Partial View Update with Ajax

  8. 8

    AJAX with partial view MVC 4 ASP.net C#

  9. 9

    Ajax (partial view) in ASP.NET MVC 5 is not working - always open just partial view alone

  10. 10

    Ajax (partial view) in ASP.NET MVC 5 is not working - always open just partial view alone

  11. 11

    Model binding doesn't work when multiple instances of the same partial view are called dynamically with ajax.actionlink in MVC 5

  12. 12

    Model binding doesn't work when multiple instances of the same partial view are called dynamically with ajax.actionlink in MVC 5

  13. 13

    Refresh Partial View Div in MVC 5

  14. 14

    Asp.net partial view doesn't work

  15. 15

    Update Partial View Within Partial View Using MVC Ajax

  16. 16

    Update Partial View Within Partial View Using MVC Ajax

  17. 17

    MVC Ajax with Dynamic Partial View Creation

  18. 18

    MVC Ajax returning Partial view but it is not showing

  19. 19

    AJAX request for a loaded partial view -MVC

  20. 20

    Returning a partial view with Ajax, MVC 3

  21. 21

    JQuery Ajax MVC Partial View Not working

  22. 22

    parserrror SyntaxError: Unexpected token < - Load Partial View using jQuery Ajax in ASP.NET MVC 4

  23. 23

    asp.net MVC ajax does post back instead of render partial view in my div

  24. 24

    When to use Partial view in ASP MVC?

  25. 25

    View doesn't render CSS and Javascript in ASP.NET MVC

  26. 26

    ASP.Net MVC doesn't map parameters for ajax call

  27. 27

    ASP.NET MVC with AJAX doesn't work as expected

  28. 28

    Webpack hot module doesn't refresh the browser

  29. 29

    Publishing doesn't update the partial [ C#/MVC/ASP.Net ]

HotTag

Archive