A very noob question, but I cannot completely understand why in the code below I can only use HttpPost(so it can run) and not HttpGet. Can someone please explain?
[HttpPost]
public ActionResult checkNumFocuses()
{
//stuff happening
if (count == 3)
{
return Json(false);
}
else
{
return Json(true);
}
}
The above is my action method which returns true/false.
This is the ajax call on the fronted :
$.ajax({
type: "POST",
url: '@Url.Action("checkNumFocuses", "Home")',
dataType: "json",
success: successFunc,
error: errorFunc
});
function successFunc(data, status) {
if (data == false) {
$(".alert").show();
$('.btnfc').addClass('disabled');
}
}
I cannot undertant why if i delete the HttpPost
attribute(so it is GET by default) and change the type in the ajax call from POST to GET.