0

I have an application and I want to update the view when the success event fires. Thanks.

Controller C#

    public ActionResult Oid(int Oid)
    {
        CustomerId = Oid;
        var model = ordendao.CustomerOrder(Oid);
        return PartialView("_TreeListOrdenesPartial", model);
    }

returns a html response

Javascript code

function event(){

    $.ajax({
            url: '@Url.Action("Oid","Customer")',
            data: JSON.stringify({ "Oid": customer[0]}),
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            success: function (data) {
                // return values 
                console.log("Sucess!" + data.oid);
            },
            error: function () { console.log('error!!'); }
          });
   }
Scott Murphy
  • 448
  • 2
  • 12
Mr. Newbie
  • 382
  • 5
  • 17

1 Answers1

3

make a placeholder on your page, where you want the partialview to render:

<div id="treeListPartial"></div>

then in your ajax:

success: function (data) {
    $("#treeListPartial").html(data);
},
Jonesopolis
  • 25,034
  • 12
  • 68
  • 112