asp.net mvc - Ajax serialize with extra data MVC -
i use webgid display records have user. load webgrid in partilal view after user clicks on ajax actionlink.
@ajax.actionlink(" ", "adduserelements", "users", new { username = item.username }, new ajaxoptions() { updatetargetid = "add_research"}, new { @class = "glyphicon glyphicon-link" })
in webgrid have delete action. when click delete modal appears ask verification. click on yes , record being deleted webgrid in partial view doesn't being refreshed. update partial view use in ajax code
$("#add_research").load('/users/adduserelements');
i tried pass username serialize controller no lack
my ajax code
$(function () { $.ajaxsetup({ cache: false }); $("a[data-modal]").on("click", function (e) { $('#mymodalcontent').load(this.href, function () { $('#mymodal').modal({ keyboard: true }, 'show'); bindform(this); }); return false; }); }); function bindform(dialog) { $('form', dialog).submit(function () { $('#progress').show(); var data = $(this).serialize() + '&' + $.param({ 'username': '@model.username' }, true); $.ajax({ url: this.action, type: "post", data: data, cache: false, success: function (result) { if (result.success) { $('#mymodal').modal('hide'); $('#progress').hide(); $("#add_research").load('/users/adduserelements'); } else { $('#progress').hide(); $('#mymodalcontent').html(result); bindform(); } } }); return false; }); }
my controller
public actionresult adduserelements(string username)
any idea? thank you
Comments
Post a Comment