I'm quite new to MVC and I'm trying to call a method int one of my controllers.
<script>
function checkCardNumber() {
var content = $('#card-number').val();
var url = "AccountController/CheckRegisteredCard";
alert("content and URL are set");
$.post(url, { cardNumber: content }, function (data) {
alert(data);
});
alert("called outside of Post");
}
</script>
and here's the C# controller side:
[HttpPost]
public string CheckRegisteredCard(string cardNumber)
{
if (/*some condition*/)
{
return "";
}
else
{
return "some string";
}
}
both alerts("content and URL are set", "called outside of post") are being triggered, but the ajax part is not working at all. What am I doing wrong here?