I'm working on an ASP Mvc project, I have the following controller:
[HttpPost]
public ActionResult Asociar(int? id, int proveedorId)
{
return PartialView("Companies");
}
In my view I pass these parameters in the following way:
<a class='asociar' style='color: #004881' href='/administrador/asociar/@item.CompañiaId' id='@item.CompañiaId' title='Asociar al Proveedor'>
This is my Ajax.
$('.asociar').click(function () {
var proveedorId = $("#proveedorId");
$.ajax({
url: this.href,
type: "post",
data: proveedorId,
success: function (result) {
if (result.success) {
//Refresh
window.location.reload();
}
}
});
});
supplierId is a hidden item.
Currently both values are coming to the Controller, but I would like to know if it is the best way to do this, or if I am making an error.