2017-04-16 9 views
2

나는이 질문을 여러 번 온라인으로 여러 번 질문했습니다. 나는 모든 것을 시험해보고 행운을 잃었습니다.코르도바 화이트리스트 플러그인

데이터를 서버에 POST하고 간단한 응답을 얻으려고합니다. 앱에서 외부 소스에 액세스하려면 코드 바이 화이트리스트 플러그인을 설치해야하므로 분명히 설치했습니다.

오류 나는 돌아 얻을 : 자원을로드하지 못했습니다 : 순 :: ERR_NAME_NOT_RESOLVED

프로젝트 정보 :

  • 이있는 온천 UI 응용 프로그램
  • 코르도바 CLI 6.5.0
  • Android 버전 6.1.2
  • ,451,515,

설치된 플러그인 :

,

메타 태그 :

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> 

도구 내가 사용 : 윈도우 10, 내가 무슨 짓을 비주얼 스튜디오 2015

:

  1. 제거 된 Visua를 사용하여 Whitelist 플러그인을 다시 설치했습니다. L 스튜디오

  2. 이 플러그인을 제거한

    코르도바 플러그인 추가 코르도바 - 플러그인 - 화이트리스트

  3. 제거 된 코르도바 CLI를 통해 다시 설치 및 Github에서

    를 통해 플러그인
  4. 를 다시 설치 난했습니다 Cordova를 6.2.0에서 6.5.0으로 업데이트했습니다.

  5. 나는 e 작동하는지 확인하고 아직 아무것도 작동하지 않는지 확인하십시오.

  6. Visual Studio에서 코도 바 캐시를 지 웠습니다.

자바 스크립트 코드는 내가 사용 :

$http({ 
    method: 'GET', url: "http://mywebsite.com/simple_get.php" 
}).then(
    function (response) { 
     alert(JSON.stringify(response)); 
    }, 
    function (response) { 
     alert(JSON.stringify(response)); 
    } 
); 

jQuery를 코드도 시도 :

var settings = { 
    "async": true, 
    "crossDomain": true, 
    "url": "http://mywebsite.com/demo.php", 
    "method": "GET", 
    "headers": { 
     "content-type": "application/x-www-form-urlencoded", 
     "cache-control": "no-cache" 
    }, 
    "data": {} 
} 

jQuery.ajax(settings).done(function (response) { 
    console.log(response); 
}); 

내가 어떤 방법을 더 이상 디버깅 및 문제에 도착하는 아무 생각이 없다 도움을 크게 주시면 감사하겠습니다 ... 이것은 내 애플 리케이션을 수행하기위한 마지막 단계입니다 : (

감사

답변

0

편집 2 :

어디 아약스 기능 이상이 코드를 사용해보십시오.

$(document).ajaxError(function(e, jqxhr, settings, exception) { 
    if (jqxhr.readyState == 0 || jqxhr.status == 0) { 
     return; 
    } 
}); 

이렇게하면 상태 0 오류가 발생하고 jQuery가 그것을 무시하고 Ajax 요청을 계속할 수 있습니다.

디버깅 용도로만 사용하십시오.

편집하는 것은

는 다음을보십시오.

$.ajax({ 
    url: 'YourRestEndPoint', 
    headers: {'yourHeaderKey': 'yourHeaderValue', 
'yourHeaderKey2': 'yourHeaderValue2'}, 
    method: 'POST', 
    data: {}, 
    success: function(data){ 
     console.log('succes: '+data); 
    }, 
    error: function (jqXHR, textStatus, errorThrown){ 

     console.log(jqXHR + " " + textStatus + " " + errorThrown); 

     console.log(jqXHR.status); 

    } 
}); 

이렇게하면 오류가 조금 더 잘 기록됩니다.

질문에서 서버로 POST 데이터를 보내려고하지만 코드에서 GET 요청을 사용합니다. 엔드 포인트는 POST와 GET 또는 POST 만 허용합니다.

원본 '이름이 고쳐지지 않았습니다.'오류가있는 경우 URL이 정확한지 확인 했습니까? 제어하는 서버에서 엔드 포인트를 실행하고 있습니까? 그것은 당신이나 제 3자가 주최 한 것입니까? DNS 조회에 문제가 있습니까? 알려진 작업 끝점을 사용해도 동일한 코드가 올바르게 작동합니까?

많은 요인이나 다양한 요인으로 인해 발생할 수 있습니다.

화이트리스트 플러그인은 최신 버전의 Cordova에 자동으로 설치되어야합니다.

+0

의 URL이 올바른지, 나는 우체부와 URL을 치는 시도하고 응답이있다. 엔드 포인트 서버에 대한 완전한 제어권을 가지고 있습니다. DNS 조회가 정상입니다. 끝 점이 Ripple 에뮬레이터 내부에서 올바르게 실행됩니다. 어떻게 디버깅 할 수 있습니까? – Rizo

+0

오류 로깅을 개선하려면 편집을 참조하십시오. 또한 jQuery를 사용하여 Ajax 요청에 대한 내 형식을 시도하십시오. –

+0

그것은 POST와 GET을 모두 받아들입니다. JS가 당신에게 보냈습니다. jqHXR의 출력은 '[object Object] 컨트롤러입니다.JS (111,25) {[기능] : __proto__ {} readyState가 0, 상태 : 0 하는 statusText 오류 }' – Rizo

0

이 내 config.xml에

<?xml version="1.0" encoding="utf-8"?> 
<widget id="au.com.myapp" version="1.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps"> 
    <name> MyApp</name> 
    <description>fancy user interfaces for hybrid mobile applications. It uses uses Apache Cordova to help you build an app that targets multiple mobile platforms: Android, iOS, Windows, and Windows Phone.</description> 
    <author email="[email protected]" href="http://myappdomain.com">Author</author> 
    <content src="index.html" /> 
    <access origin="*" /> 
    <allow-intent href="*" /> 
    <allow-intent href="http://*/*" /> 
    <allow-intent href="https://*/*" /> 
    <allow-intent href="tel:*" /> 
    <allow-intent href="sms:*" /> 
    <allow-intent href="mailto:*" /> 
    <allow-intent href="geo:*" /> 
    <allow-navigation href="*" /> 
    <allow-intent href="itms:*" /> 
    <allow-intent href="itms-apps:*" /> 
    <vs:features /> 
    <preference name="windows-target-version" value="8.1" /> 
    <preference name="windows-phone-target-version" value="8.1" /> 
    <preference name="DisallowOverscroll" value="true" /> 
    <preference name="Orientation" value="portrait" /> 
    <preference name="loglevel" value="DEBUG" /> 
    <preference name="AndroidLaunchMode" value="singleTop" /> 
    <preference name="ErrorUrl" value="" /> 
    <preference name="Fullscreen" value="True" /> 
    <preference name="KeepRunning" value="true" /> 
    <preference name="SplashScreen" value="screen" /> 
    <preference name="AutoHideSplashScreen" value="false" /> 
    <preference name="SplashScreenDelay" value="20000" /> 
    <preference name="FadeSplashScreen" value="false" /> 
    <preference name="FadeSplashScreenDuration" value=".25" /> 
    <preference name="ShowSplashScreenSpinner" value="false" /> 
    <preference name="AllowInlineMediaPlayback" value="false" /> 
    <preference name="BackupWebStorage" value="cloud" /> 
    <preference name="EnableViewportScale" value="false" /> 
    <preference name="KeyboardDisplayRequiresUserAction" value="true" /> 
    <preference name="MediaPlaybackRequiresUserAction" value="false" /> 
    <preference name="SuppressesIncrementalRendering" value="false" /> 
    <preference name="TopActivityIndicator" value="gray" /> 
    <preference name="GapBetweenPages" value="0" /> 
    <preference name="PageLength" value="0" /> 
    <preference name="PaginationBreakingMode" value="page" /> 
    <preference name="PaginationMode" value="unpaginated" /> 
    <feature name="LocalStorage"> 
    <param name="ios-package" value="CDVLocalStorage" /> 
    </feature> 
    <preference name="UIWebViewDecelerationSpeed" value="normal" /> 
    <preference name="monaca:AndroidIsPackageNameSeparate" value="false" /> 
    <preference name="monaca:targetFamilyiPhone" value="1" /> 
    <preference name="monaca:targetFamilyiPad" value="1" /> 
    <platform name="android"> 
    <icon density="ldpi" src="resources/android/icon/drawable-ldpi/icon.png" /> 
    <icon density="mdpi" src="resources/android/icon/drawable-mdpi/icon.png" /> 
    <icon density="hdpi" src="resources/android/icon/drawable-hdpi/icon.png" /> 
    <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi/icon.png" /> 
    </platform> 
    <platform name="android"> 
    <splash density="land-hdpi" src="resources/android/drawable-land-hdpi/screen.png" /> 
    <splash density="land-ldpi" src="resources/android/drawable-land-ldpi/screen.png" /> 
    <splash density="land-mdpi" src="resources/android/drawable-land-mdpi/screen.png" /> 
    <splash density="land-xhdpi" src="resources/android/drawable-land-xhdpi/screen.png" /> 
    <splash density="port-hdpi" src="resources/android/drawable-port-hdpi/screen.png" /> 
    <splash density="port-ldpi" src="resources/android/drawable-port-ldpi/screen.png" /> 
    <splash density="port-mdpi" src="resources/android/drawable-port-mdpi/screen.png" /> 
    <splash density="port-xhdpi" src="resources/android/drawable-port-xhdpi/screen.png" /> 
    </platform> 
    <platform name="ios"> 
    <splash height="480" src="res/screen/ios/Default~iphone.png" width="320" /> 
    <splash height="960" src="res/screen/ios/[email protected]~iphone.png" width="640" /> 
    <splash height="1024" src="res/screen/ios/Default-Portrait~ipad.png" width="768" /> 
    <splash height="2048" src="res/screen/ios/[email protected]~ipad.png" width="1536" /> 
    <splash height="768" src="res/screen/ios/Default-Landscape~ipad.png" width="1024" /> 
    <splash height="1536" src="res/screen/ios/[email protected]~ipad.png" width="2048" /> 
    <splash height="1136" src="res/screen/ios/[email protected]~iphone.png" width="640" /> 
    <splash height="1334" src="res/screen/ios/Default-667h.png" width="750" /> 
    <splash height="2208" src="res/screen/ios/Default-736h.png" width="1242" /> 
    <splash height="1242" src="res/screen/ios/Default-Landscape-736h.png" width="2208" /> 
    <splash src="res/screen/ios/[email protected]~universal~anyany.png" /> 
    <splash src="res/screen/ios/[email protected]~universal~comany.png" /> 
    <splash src="res/screen/ios/[email protected]~universal~comcom.png" /> 
    <splash src="res/screen/ios/[email protected]~universal~anyany.png" /> 
    <splash src="res/screen/ios/[email protected]~universal~anycom.png" /> 
    <splash src="res/screen/ios/[email protected]~universal~comany.png" /> 
    </platform> 
    <plugin name="cordova-plugin-camera" spec="~2.4.0" /> 
    <plugin name="cordova-plugin-compat" version="1.1.0" /> 
    <plugin name="cordova-plugin-file" spec="~4.3.2" /> 
    <plugin name="cordova-plugin-inappbrowser" version="1.7.0" /> 
    <plugin name="cordova-plugin-splashscreen" version="4.0.2" /> 
    <plugin name="cordova-plugin-whitelist" version="1.3.2" /> 
</widget> 
+0

괜찮아 보인다. 을 사용하면 앱 외부의 모든 URL에 액세스 할 수 있어야합니다. –

+0

나는 모든 것을 시도했다. 나는 처음부터 빈 응용 프로그램을 만들었고 그냥 간단한 GET으로 화이트리스트 플러그인을 추가했는데 그것도 작동하지 않는다. PC 구성 일 수 있습니까? – Rizo

+0

어떻게 테스트하고 있습니까? 장치 또는 시뮬레이터에서? 크롬으로 테스트하고 콘솔을 검사 할 수 있습니까? –