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

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -