INTEL XDK Ajax answer not working

I am just starting to work at INTEL XDK almost a year later. I have created 20-21 android apps. Now I have uploaded a new version of aIntel xdk about 3 months ago. I have now downloaded the latest intel xdk.

I created an apk based on ajax call. The apk worked fine in the emulator, tested and also debugged the device, but while I created the apk it doesn't work on my device.

For this I tried so many permissions, suggestions that are given on the internet, added xhr.js, etc., but it didn't work as expected.

But when I created the old XDK parchments again, it was verson 1621 or older, it works correctly.

So with the latest version of the XDK I ran into ajax issue, but not in the old version. What should be the problem with the latest version of the XDK? My current version is 1912

Here is my code STRUCTURE enter image description here

index.html

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
        <meta charset="UTF-8">
        <title>Blank App Designer Cordova Web App Project Template</title>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <style>
                @-ms-viewport { width: 100vw ; min-zoom: 100% ; zoom: 100% ; }          @viewport { width: 100vw ; min-zoom: 100% zoom: 100% ; }
                @-ms-viewport { user-zoom: fixed ; min-zoom: 100% ; }                   @viewport { user-zoom: fixed ; min-zoom: 100% ; }
                /*@-ms-viewport { user-zoom: zoom ; min-zoom: 100% ; max-zoom: 200% ; }   @viewport { user-zoom: zoom ; min-zoom: 100% ; max-zoom: 200% ; }*/
        </style>

        <link rel="stylesheet" href="css/app.css">
        <link rel="stylesheet" type="text/css" href="css/index_main.less.css" class="main-less">
        <script src="jquery/jquery.js"></script>
        <script src="cordova.js" id="xdkJScordova_"></script>
        <script src="js/app.js"></script>
        <!-- for your event code, see README and file comments for details -->
        <script src="js/init-app.js"></script>
        <!-- for your init code, see README and file comments for details -->
        <script src="xdk/init-dev.js"></script>
        <script src='xhr.js'></script>
        <!-- normalizes device and document ready events, see file for details -->
    </head>

    <body>
        <div class="upage vertical-col" id="mainpage">
            <div class="grid grid-pad urow uib_row_1 row-height-1" data-uib="layout/row" data-ver="0">
                <div class="col uib_col_1 col-0_12-12" data-uib="layout/col" data-ver="0">
                    <div class="widget-container content-area vertical-col">
                        <span class="uib_shim"></span>
                    </div>
                </div>
                <span class="uib_shim"></span>
            </div>

            <div class="grid grid-pad urow uib_row_3 row-height-3" data-uib="layout/row" data-ver="0">
                <div class="col uib_col_3 col-0_12-12" data-uib="layout/col" data-ver="0">
                    <div class="widget-container content-area vertical-col">

                        <div class="table-thing widget uib_w_1 d-margins" data-uib="twitter%20bootstrap/input" data-ver="1">
                            <label class="narrow-control label-top-left">User Name</label>
                            <input class="wide-control form-control default" type="text" placeholder="User Name">
                        </div><span class="uib_shim"></span>
                        <div class="table-thing widget uib_w_1 d-margins" data-uib="twitter%20bootstrap/input" data-ver="1">
                            <label class="narrow-control label-top-left">Password</label>
                            <input class="wide-control form-control default" type="text" placeholder="Password">
                        </div>
                        <button class="btn widget uib_w_2 d-margins btn-default" data-uib="twitter%20bootstrap/button" data-ver="1" id="login"><i class="glyphicon glyphicon-ok button-icon-left" data-position="left"></i>Login</button><span class="uib_shim"></span>
                    </div>
                </div>
                <span class="uib_shim"></span>
            </div>
        </div>
        <script>
        $("#login").click(function(){
         $.ajax({
        type:'GET',
        url:'http://time.jsontest.com/',
        error: function(response, d, a){
            alert(response + d + a) ;  
        },
        success: function (response){
            alert(JSON.stringify(response));        
        }
    });
        });
        </script>
    </body>

</html>

      

+3


source to share


2 answers


There is a known ajax issue with apk built with newest Intel XDK on Android> 4.4, this is due to Cordova CLI 4.1.2 version.



In Intel XDK settings -> project -> build for Android, change the Cordova CLI version to 3.5 and ajax should work again. We are working on a fix when using the latest CLI

+1


source


@Hardik, there are some changes in the Cordova 4.1.2 security model and hence you should use the correct settings in your Intel XDK build settings. Please read this article to learn how you should set build options before building your application.



+1


source







All Articles