Software Archive
Read-only legacy content
17061 Discussions

Json with ajax works on emulator but didn`t work on APP Preview

Alberto_F_
Beginner
568 Views

 Hi, 

I was runinng my app and geting some json with ajax but it stop working int the app preview. The code is running fine in the emulator but I can`t figure out what was happened with the app preview.

I update Intel XDK to 2807, but it was working fine. Below you can find the test I'm running.

Thanks in advance for any help.

 

<!DOCTYPE html>
<html>
<head>
    <title>AJAX and XDK</title>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0;" />
    
    <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>  
    <script>
        function doJSON1() {
            $.getJSON('http://www.w3schools.com/website/customers_mysql.php', function (data) {
                alert(JSON.stringify(data));       
            }); 
        }    
        function getJsonTime () {        
        alert ("Testing Alerts!");    
        $.getJSON("http://time.jsontest.com", function(data){
	    alert(data);
	});         
        }
        
</script>
<style>
    body {font-family:arial;background-color:white}
</style>    
</head>
<body>         
    <h3>Get JSON1 - Test on W3Schools File (Internet)</h3>
    <button onclick="doJSON1()">Get JSON</button>
    <h3>Get JSON - Test Time (jsontest.com)</h3>
    <button onclick="getJsonTime()">Get JSON Time</button>
</body>
</html> 

 

0 Kudos
11 Replies
Elroy_A_Intel
Employee
567 Views

Which mobile platform are you testing on? If Android, I recommend using the Debug Tab to evaluate the network traffic of your application.

0 Kudos
Anusha_M_Intel1
Employee
567 Views

This might be your problem: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing

Adding <script src="xhr.js"></script> solves the issue. I tested it on App Preview for Android. 

0 Kudos
Alberto_F_
Beginner
568 Views

Hi Elroy,

I  tried with that but is not working.I don't see what I'm missing. I dont understand what happened, because it was working on APP Preview with any modification and from last two or three days all the test I was doing with the sample apps stops running.

I'm testing with app preview in Android but isn't working on Samsung S4  (5.01) or BLUE LIFE PURE MINI  (4.2.1).

Thanks in advance for any help.

AF

<!DOCTYPE html>
<html>
<!--
  * Please see the included README.md file for license terms and conditions.
  -->
<head>
    <title>Blank Cordova Mobile App Project Template (Lite)</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">

    <!-- see http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-dont-forget-the-viewport-meta-tag -->
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <style>
        /* following two viewport lines are equivalent to the meta viewport statement above, needed for Windows */
        /* see http://www.quirksmode.org/blog/archives/2014/05/html5_dev_conf.html and http://dev.w3.org/csswg/css-device-adapt/ */
        @-ms-viewport { width: 100vw ; zoom: 100% ; }  @viewport { width: 100vw ; zoom: 100% ; }
        @-ms-viewport { user-zoom: fixed ; }           @viewport { user-zoom: fixed ; }
    </style>

    <script src="cordova.js"></script>          <!-- phantom library, needed for Cordova api calls, added during build -->
    <script src="js/app.js"></script>           <!-- recommended location of your JavaScript code relative to other JS files -->
    <script src="xdk/init-dev.js"></script>     <!-- normalizes device and document ready events, see README for details -->
    <script src="xhr.js"></script>          <!-- phantom library, needed for XDK CORS -->
    <script src="intelxdk.js"></script>   <!-- phantom library, needed for XDK api calls -->
    <script src="js/init-dev.js"></script>
    <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>  
    

    <script>
            function doJSON5() {
            $.getJSON('http://www.w3schools.com/website/customers_mysql.php', function (data) {
                alert(JSON.stringify(data));
                
            }); 
        }
    </script>
        
</head>

<body>

    <p>Hello, Cordova!</p>
    
        <h3>Get JSON5 - Test on W3Schools File (Internet)</h3>
    <button onclick="doJSON5()">Get JSON</button>

</body>
</html>

 

 

0 Kudos
Rui_C_
Beginner
568 Views

For the 4th time I've submitted an app called wwmob successfully through Intel XDK version 2807 but the in the phone's installed app launcher icon keeps being the Cordova logo (kind of "cubic" Android). Could someone tell me where in the process of develop and build I should have to enter the right icon? Is there a way for replacing the Cordova icon by the right one in the installed app? Thanks. 

   

0 Kudos
Anusha_M_Intel1
Employee
568 Views

@Rui, check out this faq- https://software.intel.com/en-us/xdk/faqs/cordova#cordova-cli-build-icons

The Hello Cordova additions file is a fine example of how to include icons. Please use that as a reference - https://github.com/gomobile/sample-hello-cordova/blob/master/intelxdk.config.additions.xml

0 Kudos
Elroy_A_Intel
Employee
568 Views

Alberto F. Are you seeing any network traffic activity in your application via the Debug Tab's Chrome Developer Tools? Are any of your HTTP requests returning a response?

0 Kudos
Alberto_F_
Beginner
568 Views

Hi Elroy,

I can't see the phone on the debug tab... I trying with the drivers, but I check the App Preview on IPAD and its working fine, but the same app or code it's not working on App Preview on Android (S4, BLUE or Samsung Galaxy TAB 3).

Thanks in advance for any help.

AF

 

 

 

0 Kudos
Alberto_F_
Beginner
568 Views

Hi Elroy, 

I just checked on debug tab and it works on Blue Life Pure Mini, but still can`t get it to run on APP Preview.

Thanks in advance for any help.

AF

0 Kudos
Wesley_S_1
New Contributor I
568 Views

Is there any news over this?
Since i've updated to 2807 i'm having the same issue.

All my ajax-calls aren't executed anymore :(

0 Kudos
Alberto_F_
Beginner
568 Views

Hi Wesley, 

No, I don`t have any news about it.

The ajax calls are working fine on the App Preview on IPAD but do not work on APP Preview on Android on any of my device.

They work on android only on the DEBUG tab.

AF

 

 

 

0 Kudos
PaulF_IntelCorp
Employee
568 Views

There are some issues with App Preview 2.7 and network access that engineering is looking into. Look for an update via the Google store.

0 Kudos
Reply