I have a C # .NET MVC 5 project. I am trying to send a GET request from ajax to a controller method on the server. The problem is that although this jquery is being called, GET always returns 404. Here is the js:
var theArguments = { "prefix": prefix, "level": level, "number": number };
$.ajax({
url: "GetMasteryObjective",
type: "GET",
data: theArguments,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
console.log("Successfully queried the database to validate the given mastery objective.");
},
error: function () {
console.log("There was an error with trying to validate the mastery objective with the database.");
}
});
As you can see, I tried several options for how variables are passed (commented out). This is a controller method that never hits.
[HttpGet]
public static MasteryObjective GetMasteryObjective(String prefix, String level, String number)
{
}
Other methods in one controller cannot be sent. So maybe something I don’t understand about GET? I understand that it must be valid for sending variables with a GET request.
source
share