I have the following code that at jquery, try to bring the data from a partial view and show them in the main view. the issue is that when you start the process, and click on the corresponding button, the load event, does not load anything, therefore the data is not inserted in the view.
This is the actiontresult in the controller that brings me the data (simplify it for purposes of showing it here)
[HttpGet]
public async Task<ActionResult> ObtenerCliente()
{
Cliente cliente;
cliente = new Cliente();
cliente.Nombre = "raul";
cliente.Apellido = "perez";
cliente.edad = 23;
objCliente.Add(cliente);
cliente = new Cliente();
cliente.Nombre = "Juan";
cliente.Apellido = "torres";
cliente.edad = 22;
objCliente.Add(cliente);
return PartialView("DetalleCliente", objCliente);
}
here is the main view and the script where I make the call
<script type="text/javascript">
$(document).ready(function () {
$('#btn1').click(function () {
$('#dvDetalleCliente').load('/home/ObtenerCliente');
});
});
</script>
When I debug the execution, in chrome, I can clearly see that the click event is executed, but apparently the load is not loading the data .. the control is never delivered to the actionresult in the controller.
Any idea what I'm doing wrong?
Greetings