Software Archive
Read-only legacy content
17061 Discussions

How to use build function

Denis_S_
Beginner
380 Views

Hi,

recently I have written a code for an application and that code works correctly using the emulators of INTEL XDK but, when I create the file .apk for my smarthphone and install it, It opens correctly but it doesn't work. For example in the following code I want that when you click on botton appear an "alarm" page and is send a web request. The web page ask an authorization and I use the "xmlhttprequest" function for it. I repeat that it works correctly using emulator but not when I install it on my smarthphone.

Could you help me?

thank you very much

(ps: "url" is the url of my personal webpage that is protected by admin and password)

<!DOCTYPE html>
<html>


    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="jqm/jquery.mobile-min.css">
        <title>Blank App Designer Packaged Web App Project Template</title>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">

        <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=no">

        <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% ; }

        </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="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>
        <!-- normalizes device and document ready events, see file for details -->
        <script type="application/javascript" src="lib/jquery.min.js"></script>
        <script type="application/javascript" src="jqm/jquery.mobile-min.js" data-ver="0"></script>
    </head>

    <body>

        <div class="upage vertical-col left" id="mainpage" data-role="page">
            <a class="widget uib_w_1 d-margins" data-uib="jquery_mobile/button" data-ver="0" onclick="apertura()" data-role="button" data-theme="a">Button</a>

        </div>
        <script type="text/javascript">
            function apertura(){
                var request =XMLHttpRequest();
                request.open("GET", "url",false,"admin","password");
                request.send(null);

                alert('messaggio')
            }
        </script>
    </body>

</html>

 

0 Kudos
1 Reply
Hamilton_Tenório_da_
Valued Contributor I
380 Views

Try to use like this:

function apertura(){
$.ajax ({
                url: "http://.......",

                dataType:"application/json", //o que espero receber
                success: function(retorno) {
                    funPegaTempoRefresh(retorno);
                },
                error: function (jqXHR,textStatus,errorThrown) {
                    funAvisaProblema(jqXHR,textStatus,errorThrown)
                },
            }); 

}

0 Kudos
Reply