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!!'); }
});
}
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);
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.