Friends, I appeal to you again, what I want to know is how I can travel this json.
{"codigo_postal":"84100","municipio":"Nogales","estado":"Sonora","colonias":["Aguajito de la Morita","Felizardo Amador","Hector Soto","Jorge Leal","La Morita (El Aguajito)","Casildo Santa María","Ruben Martínez Fimbres","El Choclo","El Tapiral","Los Cuervos","Rubén Darío Rodríguez","La Arizona (La Hacienda)","Los Castro","Rafael Carrizosa","San Miguelito","Rubén Barnet","Elena Rodríguez","Jiráhui","José Ignacio Real","Luis Santa María","Agua Caliente","Casas Blancas","La Angostura","La Pasadita","Doña Chepa","El Aguajito","El Tascali","La Ciénega","Las Borregas de Abajo"]}
What is the idea that colony data put them in a combobox.
This is the code that I have made but I do not know how to go through the colonies.
$('#BtnValidarCodPostal').on('click', function () {
var CodigoPostal = $('#CodPostal').val();
$("#ValidandoCodigo").show();
if (CodigoPostal != "" || CodigoPostal != "")
{
$.ajax({
type: 'GET',
url: _urlBase + "CodigoPostal/GetCodigoPostal",
dataType: 'json',
data: { Codigo: CodigoPostal },
success: function (emp) {
$.each(emp, function (i, item) {
console.log(item.Colonia);
});
$("#ValidandoCodigo").hide();
$("#ResulCodPostal").show();
$('#Estado').val(emp.codpos.Estado);
$('#Delegacion').val(emp.codpos.Municipio);
//console.log(emp);
},
error: function (xhr, status) {
alert(xhr.responseText);
// bindForm();
}
});
}
})
and this is the action result
public JsonResult GetCodigoPostal(string Codigo)
{
List<MtoCodigoPostal> CodigoPostal = db.MtoCodigoPostales.Where(o => o.CodigoPostal == Codigo).ToList();
return Json( new {codpos = CodigoPostal.Take(1).ToList() }, JsonRequestBehavior.AllowGet);
// return Json(new { clave = Result }, JsonRequestBehavior.AllowGet);
}
I would appreciate the support provided