2017-04-10 1 views
0

JQuery에서 webservices를 사용하여 데이터 가상화보기에서 값 목록을 검색하려고합니다. 이것은 내가 지금까지 가지고있는 것이고 나는 error을 경고 (xhr.error)에서 얻고있다. 내가 간과 할 수있는 분명한 것들로 도와 줄 수 있습니까? 많이 고맙습니다webservice 호출을 사용하여 항목 가져 오기

<script src="/jquery-1.11.1.js"></script> 
<script src="/jquery.SPServices-2014.02.min.js"></script> 
<script type="text/javascript" language="javascript"> 

$(document).ready(function() { 
$.ajax({ 
    type: "POST", 
    url: "http://xxx/soap11/ValidateSourceCode?wsdl", 
username: "xyz", 
    password: "xyz", 
    dataType: "xml", 
    data: {}, 
    processData: false, 
    contentType:"text/xml; charset=\"utf-8\"", 
    success: function (msg) { 
      alert($(msg).text()); 
      //console.log($(msg).text()); 
    }, 
    error: function(xhr, status, error){ 
       alert(xhr.status); 
       alert(xhr.error); 

     } 
    }); }); 


    </script> 
+0

'xhr.error'처럼 보이는 것이'function'입니다. 'xhr.error()'로 대체하려고 시도하십시오 – Red

+0

또는'alert (error)' 마찬가지로'$ (msg) .text() 대신 성공 핸들러'alert (msg) '. –

답변

0

디버거의 네트워크 탭을 살펴보십시오. 동일한 출처 정책으로 인해 400 오류가 발생했습니다. 이는 기본적으로 애플리케이션 호스팅과 다른 서버에 아약스 요청을 할 수 없다는 것을 의미합니다. 그냥 서비스 메서드에서 데이터를 가져 오는 경우

https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

0

을 jquery.soap 사용해 볼 수 있습니다 wsdl (= 비누 webservice) jQuery에서? SoapClient (예 : PHP Soapclient)를 사용해야합니다.

그리고 당신의 아약스 다시 전화 : 당신의 PHP 스크립트 내부

$.ajax({ 
    type: "GET", 
    url: "/api/yourLocalSoapClient.php", 
    data: {query:'testApi'}, 
    contentType:"text/xml; charset=\"utf-8\"", 
    success: jqSuccess, 
    error: jqError 
}); 

넣어 사용자 이름/암호 및 사용 SoapClient : https://github.com/doedje/jquery.soap

:

http://php.net/manual/fr/class.soapclient.php

당신은의 jQuery soapclient을 시도 할 수 있습니다

하지만 공용 응용 프로그램 인 경우 금지되어 있습니다. 웹 서비스에 대한 사용자/암호가 노출됩니다. p hp, 자신의 json을 반환하십시오.

관련 문제