When a key is pressed and released, a JavaScript function is triggered. The function is supposed to call a controller action and return a result, but instead, I am receiving a 404 error. I have set breakpoints at the beginning of the controller action, but they are never triggered. I suspect that the issue lies in the type of request being made or in the data being sent along with it.
The code is written in C# MVC .NET 6
Java Script::::
function GetThingsContaining() {
$.ajax({
type: "POST",
url: "GetThingsContaining/MyController",
data: { searchCriteria: "afd" },
dataType: "json",
success: function (data) {
//do work if successful
},
error: function (data) {
alert("Well that stinks")
},
});
}
Controller Action
[HttpPost]
public IActionResult GetThingsContaining(string searchCriteria) {
return PartialView("~/Views/Investments/_SearchDataList.cshtml", returnModel);
}
Even though I have set a breakpoint at the return statement, it is never reached. The browser's dev tools indicate a 404 error.