We need to send the data to the server by appending it within formdata in javascript. In javascript, we have handle this as like below.
var ajax = new XMLHttpRequest();
ajax.open("POST", url, true);
var formData = new FormData();
var obj = {url: "uploadUrl",type: 'POST', mode: true};
formData.append('myData', JSON.stringify(obj));
ajax.send(formData);
In server end, we have the method as like below.
public void Save(MyModel args) {
....
}
public class MyModel
{
public MyObj myData { get; set; }
}
public class MyObj
{
public string url { get; set; }
public string type { get; set; }
public bool mode { get; set; }
}
args.myData always received as null. How to receive the data sent from the client here in this format ? Suggest your ideas.