javascript - ajax post request with multiple paramaters -
my controller:
[httppost] public iactionresult userrolechanged(string rolename,string username) { var = rolename; var b = username; return redirecttoaction("usermanager"); } script in view:
if (window.confirm('are sure want change role?')) { jquery.ajax({ type: "post", url: "@url.action("userrolechanged", "dashboard")", datatype: 'json', data: { 'rolename': this.text, 'username': 'somename'}, cache: false, success: function (data){ window.location.href = data; }, failure: function (data) { } })}; when run script above userrolechanged action not invoke. if try remove username variable data in ajax userrolechanged action method invokes without problem. how can pass multiple data controller? wrong code?
remove datatype: 'json' ajax, , try again. trying values on server side normal variable, datatype: 'json' not required here.
Comments
Post a Comment