2
I am trying to send the result of a Webapi that is consumed via javascript on the page to a method in the controller that will make a persistence with this 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 take the result of the first ajax and send to this method ?
Do you want to take the result of this get and do a post for your controller? That’s it?
– Aesir
You want to send the value of
data
received by post at url?– Bruno Heringer