2

I'm trying to make a sort with javaScript on my function I'm calling a method on the controller. That method is an actionResult, on that method my model that I'm using on the view is refreshing but I don't know how to refresh that on the view. I mean how to go to the return on the method in the Controller and stop the thread ajax. I'm trying this.

function sort(callback) {
    $.ajax({
        url: '@Url.Action("Method","Controller")',
        type: "POST",
        async:false,
        data: { query: null, search: $('#QueryString').val(), sort: sortOrder, sort_value: sortValue,portfolioId:-1},
        success: function (data) {
            alert("sort success");

        },
        error: function (data) {
            alert("error");

             }
    })
};         
tereško
  • 58,060
  • 25
  • 98
  • 150
UserEsp
  • 415
  • 1
  • 7
  • 29
  • 1
    Perhaps [this](http://stackoverflow.com/questions/19392212/how-to-use-jquery-or-ajax-to-update-razor-partial-view-in-c-asp-net-for-a-mvc-p) will help. – Jasen Jan 05 '16 at 18:38
  • Thanks Jasen the data value works for me – UserEsp Jan 05 '16 at 21:02

1 Answers1

0

Use $("body").html(data); on success statement. I hope this will useful for someone

 function sort() {
      $.ajax({
          url: '@Url.Action("Method","Controller")',
          type: "POST",
            data: {sort: sortOrder, sort_value: sortValue,},
            success: function (data) {
                $("body").html(data);
            },
      })
    };   
UserEsp
  • 415
  • 1
  • 7
  • 29