Sending Data from Javascript to Asp net Core -


i need send data js core.

in have model

public class addemployeevm {      public employeevm employee {get; set;}      publi list<privilegesvm> privileges {get;set;} } 

employeevm

public string firstname {get;set;} public string lastname {get;set;} public iformfile image {get;set;} 

list of privileges

public string userid {get;set;} public string privilegeid {get;set;} public string privilegename {get;set;} public bool create {get;set;} public bool read {get;set;} public bool update {get;set;} public bool delete {get;set;} 

so, in api need receive complex data files fields

i cant come data append, because can't receive list of privileges, can't go json solution becouse can't send files...

so please me, javascript code valid?

the below javascript code posting values using ajax.

$.ajax({         type: 'post',         contenttype: 'application/x-www-form-urlencoded; charset=utf-8',         data: { parameter1: value1, parameter2: value2},         url: "/controllername/actionname",         cache: false,         success: function (data) {             // process received data.         }     }); 

in below controller, parameter names must match ones being posted using ajax.

[httppost] public iactionresult actionname(string parameter1, string parameter2) {  } 

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? -