2017-07-04 87 views
0

我想從這個網址全光照的Jquery AJAX https://sisa.msal.gov.ar/sisa/services/rest/puco/44003375jQuery的阿賈克斯獲得XML解析錯誤

通過瀏覽器,我可以看到這個得到一個XML:

This XML file does not appear to have any style information associated with it. The document tree is shown below. 
<puco> 
<resultado>OK</resultado> 
<coberturaSocial>O.S.P. CIUDAD AUT</coberturaSocial> 
<denominacion>AGOSTINO RODRIGO LEONARDO</denominacion> 
<nrodoc>44003375</nrodoc> 
<rnos>901001</rnos> 
<tipodoc>DNI</tipodoc> 
</puco> 

但這樣做的時候:

var id=44003375; 
$.ajax({ 
    type : "GET", 
    url : 'https://sisa.msal.gov.ar/sisa/services/rest/puco/'+id, 
    dataType :"JSONP", 
    jsonp: true, 
    success : function(xhr){ 
     alert(JSON.stringify(xhr)); 
    }, 
    error : function(httpReq,status,exception){ 
     var clientid = $(httpReq).text(); 
     alert(JSON.stringify(httpReq)); 
    } 
}); 

返回「解析錯誤」...我如何通過Ajax獲取瀏覽器顯示的內容?

+0

XML不是JSON –

+0

當然可以,但只有這樣,效應初探URL內容。 dataType:「xml」,「text」,「html」沒有任何迴應 –

回答

0

我解決了,但PHP

<?php 
    $response = file_get_contents('https://sisa.msal.gov.ar/sisa/services/rest/puco/44003375'); 
    $response = new SimpleXMLElement($response); 
    dd($response); 
?>