i try to call a method in my sitefinity project using mvc models, but the program tell Failed to load resource: 404, and never find the controller and i dont know how to resolved, this is my code
Jquery call:
function myFunction(postId) {
$.ajax({
url:'/CombosController/GetCantones',
type: 'POST',
dataType:"applicaiton/json; charset=utf-8",
data: { idprovincia: postId },
success: function(data) {alert("success");},
error: function() {alert("error");}
})
}
Action of controller:
[WebMethod]
public static ActionResult GetCantones(int idprovincia)
{
CombosBL.Provincias.JsonListados metodos = new JsonLIstados();
List<ClaseCantones.NCanton> ListaPropiedades = metodos.GetCantonesByIdProvincia(idprovincia);
var lista = ListaPropiedades;
return new JsonResult { Data = lista, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
you can call your MVC action in two ways
First way
Example of MVC widget:
Second way
Creating custom URL route to the action of your controller
Example how to do that for your case. Global.asax.cs code:
And after that, you can call http://yourhost/api/getcantones.