$("#icon-cep").click(function () {
var cep = $(".cep").val();
console.log(cep);
$.ajax({
type: "POST",
url: '@Url.Action("BuscaCep")',
data: { cep: cep },
success: function (result) {
console.log(result);
},
error: function (result) {
}
});
method no controller
[HttpPost]
public string BuscaCep(string cep)
{
WebServiceCorreio.AtendeClienteClient ws = new WebServiceCorreio.AtendeClienteClient("AtendeClientePort");
var dados = ws.consultaCEP(cep);
if (dados != null)
{
var json = JsonConvert.SerializeObject(dados);
return json;
}
return null;
}
But it is returning an empty object, I made several changes, but none worked. Can anyone give me a light of what might be wrong ??