0
entripy created
Hi, I am using following ajaz call with abp.ajax to controller.
$("#mapBtn").on("click", function (e) {
var data = buildDataObject();
abp.ajax({
url: "Map",
data: JSON.stringify({
ColumnName1: $("#selector1").val(),
HasHeader: $("#selector2").is("checked"),
}),
content: "application/json; charset=utf-8",
type:'post'
}).done(function (data) {
abp.notify.success('Created ');});
});
My model class:
public class MyClass {
public string ColumnName1 { get; set; }
public bool HasHeader { get; set; }
}
My controller action is as follows: I used [DisableValidation] on the controller.
[HttpPost]
public async Task<ActionResult> Map([FromBody] MyClass data)
{
// data is null
return View("Import");
}
data is always null. When I replaced myclass with dynamic type; i do get data back but its not in a format I can convert to my model. Can you point me to what is missing?
4 Answer(s)
-
0
try remove:
JSON.stringify
data: { ColumnName1: $("#selector1").val(), HasHeader: $("#selector2").is("checked") };
-
0
I tried that already. its not working.
-
0
Please share the name of your controller and the ajax network request in your browser console/network panel.
-
0
Hi @entripy
I am facing same issue.
Can you please post the solution?
Cheers, Vikas