Falla el json desde php
Publicado por GIULIANO (74 intervenciones) el 20/09/2018 18:54:47
Estoy tratando de recibir una consulta al padron de afip, en la consola del navegador se ve perfecto el JSON separado por corchetes, pero jquery no entra al evento success. Falla el requerimiento:
Obtengo Requested JSON parse failed..que puede ser..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
include_once ($_SERVER['DOCUMENT_ROOT'].'/gestionweb/includes/afip/wsaa-client.php');
define ("URLS", "https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA4?WSDL");
$CUIT=$_POST['CUIT'];
$CUITI=(float)$CUIT;
if (isset($_POST['CUIT'])){
$wsdl_p5="https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA4?WSDL";
$padron = new SoapClient($wsdl_p5, array(
'soap_version' => SOAP_1_1,
'location' => URLS,
'exceptions' => 0,
'trace' => 1)
);
$TA = simplexml_load_file("C:\\xampp\htdocs\gestionweb\includes\afip\TA.xml");
$resultado = $padron->getPersona(
array(
'token' => $TA->credentials->token,
'sign' => $TA->credentials->sign,
'cuitRepresentada' => 20357161178, // es el cuit con el que pedi el certificao
'idPersona' =>$CUITI,
)
);
echo json_encode($resultado);
}
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
$(document).ready(function() {
$("#buscar").click(function(){
var CUIT=$("#cuit1").val();
$.ajax({
type: "POST",
url: "//localhost/gestionweb/includes/afip/consultaPadron.php",
data: {"CUIT":CUIT},
dataType:"json",
error: function(){
alert("error petición ajax");
},
success: function(cli){
$.each(data, function(i, item) {
});
$("#Nombre").val(cli[0].nombre);
}}).fail( function( jqXHR, textStatus, errorThrown ) {
if (jqXHR.status === 0) {
alert('Not connect: Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (textStatus === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (textStatus === 'timeout') {
alert('Time out error.');
} else if (textStatus === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error: ' + jqXHR.responseText);
}
});
});
});
Obtengo Requested JSON parse failed..que puede ser..
Valora esta pregunta


0