I want to take a JSON response from an external server but I cannot pull apart each field in the response.
<script>
function padronafip() {
$.ajax({
url: 'https://soa.afip.gob.ar/sr-padron/v2/persona/27293892046',
datatype: 'json',
success: function(data) {
var JSONString = JSON.stringify(data);
console.log(JSONString);
}
});
}
</script>
Here follows the response:
{"success":true,"data":{"idPersona":27293892046,"tipoPersona":"FISICA","tipoClave":"CUIT","estadoClave":"ACTIVO","nombre":"SPITALE LAURA ANDREA","tipoDocumento":"DNI","numeroDocumento":"29389204","domicilioFiscal":{"direccion":"25 DE MAYO 198 - ESQUINA: RIVADAVIA","localidad":"PIGUE","codPostal":"8170","idProvincia":1},"idDependencia":111,"mesCierre":12,"fechaInscripcion":"1997-07-03","categoriasMonotributo":[{"idImpuesto":20,"idCategoria":44},{"idImpuesto":21,"idCategoria":11}],"impuestos":[20],"actividades":[474010,951100]}}
I want to fill differet text boxes with some of the data.
Thanks!
remove this:
var JSONString = JSON.stringify(data);
console.log(JSONString);
you can then access your data in this manner:
$.ajax({
url: 'https://soa.afip.gob.ar/sr-padron/v2/persona/27293892046',
datatype: 'json',
success: function(result) {
console.log(result.data.nombre);
}
});