Hi, I'm learning to use AJAX in ASP NET, I want to run a method through js, but I'm not sure how to reference it, the method I want is in my controller but when I give it the route it does not tell me it does not find anything .
@model PCotiza_compras.Models.Departments
@{
ViewBag.Title = "Kyo_2";
}
<script src="~/Scripts/jquery-1.10.2.js"></script>
<div id="Content"></div>
<input type="button" name="name" value="try" onclick="DepListQuery()" />
<script>
function DepListQuery() {
$.ajax({
type: 'POST',
url: '../../Controllers/HomeController/.GetData()', //aquí no sé si estoy bien D:
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
$("#Content").text(response.d);
},
failure: function (response) {
alert(response.d);
}
});
}
</script>
And this is the method in my controller
[Authorize]
public ActionResult Kyo2()
{
return View();
}// End Get/kyo 2
[WebMethod]
public static string GetData()
{
return "This string is from Code behind";
}