2017-01-17 7 views
0

を実行していない、私はAJAX REST通信をテストするためにこのコードを持っている:Chromeでこのコードを実行するPhoneGapのはAPK私のPhoneGapアプリでPOSTアクション

$(document).ready(function() { 
     $("#test").click(function() { 
     alert("OK"); 
     $.ajax({ 
     type: "GET", 
     data: {}, 
     url: "http://localhost:8080/test-notifier-web/RegisterServlet", 
     }); 
    }); 
}); 
<div class="row col-centered"> 
    <button type="submit" id="test">Submit</button>     
</div> 

はOKですが、私は私のコンソールとすべての作品にログインします良い。私がcordova build androidとapkを構築し、私のGenymotionデバイスでそれをテストすると、私はサーバーからの応答を取得しません。ある時点で、Web経由でGenymotionブラウザを使ってテストするのはOKです。

私はこのコードで新しい空のアプリケーションを作成しました。これはapkとうまく動作しています。誰でも私を助けることができますか?

これは私のconfig.xmlにある:あなたがコンテンツ[セキュリティを追加する必要があり、あなたのconfig.xmlに

<allow-intent href="http://*/*" /> 
<allow-intent href="https://*/*" /> 

「を許可し、意図」メタ情報を追加する必要が

<?xml version='1.0' encoding='utf-8'?> 
<widget id="it.paytas.mobile" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"> 
    <name>Paytas Mobile</name> 
    <description> 
     A blank PhoneGap app. 
    </description> 
    <author email="[email protected]" href="http://phonegap.com"> 
     PhoneGap Team 
    </author> 
    <content src="index.html" /> 
    <access origin="*" /> 
    <preference name="DisallowOverscroll" value="true" /> 
</widget> 
+0

config.xmlとContent-Security-Policyを貼り付けてください。 – Eric

+0

@Ericがconfig.xmlを投稿しました。どこにContent-Security-Policyがありますか? – slash89mf

答えて

0

あなたのindex.htmlを

<meta http-equiv="Content-Security-Policy" content="default-src 'self' gap://ready file://* 'unsafe-inline' *; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; img-src *"> 

へのポリシーメタはまた、あなたがcordova-plugin-whitelistプラグインがインストールされていることを確認してください。

+0

これはまさに私の問題でした。このように修正しました、ありがとう – slash89mf

関連する問題