I am passing data from view to controller to post to database, I am using a database first approach of the entity framework, so models is set up ok,
I have an empty array var formArray = [];. Data from input fields is captured as
var OPDNo = $('[name= OPDNo]').val();
var Re = $('[name= re]').val();
var Le = $('[name= le]').val();
in my view, I have input variables which I have put them into a formData{} as
var formData = {
'OPDNo': OPDNo,
'VAFRE': Re,
'VAFLE': Le
};
The OPDNo, Re, Le are both input fields. I am passing data using Ajax as below:
if (formData != null) {
$.ajax({
url: '/EMR/SaveVisionScreening',
type: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify({ formArray: formData, selectValues: selectValues }),
success: function () {
showNotification("Record Saved Successfully", "info", true);
}
});
}
In my controller,
[HttpPost]
public void SaveVisionScreening(string formArray, string [] selectValues)
{
//Code...
}
When I debug, the controller returns a null on string formArray, I have also set ***traditional: true ** but it is still null. I have checked some solutions here but it has not helped me solve it.
