I'm trying to send the result of a WebAPI that is consumed via javascript on the page to a method in the controller that will do a persistence with that data
this is javascript
$('#CodigoCep').blur(function() {
var cep = $('#CodigoCep').val();
$.getJSON("http://localhost:13943/cep/" + cep,
function (data) {
$('#Logradouro').val(data.logradouro);
$('#Bairro').val(data.bairro);
$('#Cidade').val(data.cidade);
$('#Estado').val(data.estado);
})
.fail(function () {
$('#Logradouro').val('');
$('#Bairro').val('');
$('#Cidade').val('');
$('#Estado').val('');
});
});
This is the method in the controller:
[HttpPost]
private void CadastraCep(string modelo)
{
... persistir modelo
}
How to get the result of the first ajax and send to this method?