Dear Sirs.
Please Help. I'm new in Ajax what I'm doing wrong.
Do I need some action on startup.cs ? or ..
Here is a Controller Code
[HttpPost]
public IActionResult MyMethod([FromBody] int paramint, [FromBody] string filename)
{
if (filename != null)
return (Json(true));
return (Json(false));
}
and JS Code
function Test() {
$.ajax({
type: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
dataType: "json",
url: '/Home/MyMethod',
data:
{
"paramint": 2,
"filename" : "file.txt"
}
,
error: function () {
alert("Cant Access at all");
},
success: function (operationState) {
if (operationState === true) {
alert("Finaly :)");
}
else {
alert("Still not set the parameters");
}
}
});
}