Software Archive
Read-only legacy content
17061 Discussions

Problem in AJAX and Whitelist

Guilherme_Vieira
Beginner
1,183 Views

I'm big problem, I developed an APP, it works fine in the emulator but when I run it in Builder and install the mobile AJAX does not work, I tried every way put the Whiltelist with "*" but it worked. Could someone tell me if I need to include a plug-in index.html? XDK put in the config the asterisks but did not work well. Follow the prints of my code.

temp2.jpg

temp1_0.jpg

0 Kudos
5 Replies
PaulF_IntelCorp
Employee
1,183 Views

Don't trigger your app off the document ready event, the Cordova subsystem is not yet ready. You need to trigger off device ready. Or, if you include the init-dev.js file, you can trigger off the app.Ready event, which combines device ready and document ready.

The Cordova features, including the whitelist feature, are not available until the cordova.js subsystem has finished initialization. That initialization occurs in the native code part of your app, which runs in a separate thread.

0 Kudos
Guilherme_Vieira
Beginner
1,183 Views

Good morning, thank you for your help.
My code is so now, tell me what the correct order to let the JS.

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>

     <script src = "intelxdk.js"> </ script>
     <script src = "cordova.js"> </ script>
     <script src = "xhr.js"> </ script>
     <script src = "js / app.js"> </ script>
     <script src = "js / init-app.js"> </ script>
     <script src = "XDK / init-dev.js"> </ script>

0 Kudos
PaulF_IntelCorp
Employee
1,183 Views

Do not load files from a network, if your user's device has no network connection, or has a flaky network connection, your app is going to be "dead in the water." It will freeze and not start, resulting in a very unhappy user. You need to download those libraries and copy them into your project folders (somewhere inside of the www directory) and then reference them locally (similar to the others in the list).

The order you have should be fine, once you fix how you load those CSS nad JS files. Also, you can get rid of the intelxdk.js and xhr.js file, they are no longer required.

0 Kudos
Guilherme_Vieira
Beginner
1,183 Views

Hello my friends good night, I can not do AJAX with external LINK PHP work, it simply in Android goes unanswered.

In crosswalk Android works perfectly, but when generate only for Android and install the phone it does not.

I looked like the prints of my settings, to know what I did wrong.  

The solution would be to insert this code in my index.html ?

Content Security Policy:

<meta http-equiv=“Content-Security-Policy” content=“default-src ‘self’ data: gap” https://ssl.gstatic.com; style-src ‘self’ ‘unsafe-inline’; media-src *”>
<meta http-equiv=“content-Security-Policy” contnet=“default-src ‘self’ https:”>

I thank you again for your help.

 

0 Kudos
PaulF_IntelCorp
Employee
1,183 Views

Crosswalk builds are for Android. Do not use the Android-only builds unless you have a very good reason. The 2.x and 4.x Android webviews are inconsistent, unreliable and based on very old web runtimes. This is one of the key reasons we provide the Crosswalk solution.

0 Kudos
Reply