Noob question r.e

Noob question r.e

Ginger G.'s picture
This is the code:
function apiCall(action, params) {
    var callURL = siteURL + apiURL + "action=" + action + "&" + params, xmlHttp = null;

    xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", callURL, false);
    xmlHttp.send();
    return xmlHttp.responseText;
}

This is the error:

Uncaught NetworkError: A network error occurred. /C:/Users/MYUSERNAME/AppData/Local/Intel/XDK/xdk/components/client/emulator/ripple.js:60282
(anonymous function) /C:/Users/MYUSERNAME/AppData/Local/Intel/XDK/xdk/components/client/emulator/ripple.js:60282
apiCall gingerlib.js:17
doLogin gingerlib.js:26
onclick index.html:79

 

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Ginger G.'s picture

bump

Paul Fischer (Intel)'s picture

Sorry, but not much to go on with the info you've provided. Does this work in a standard browser? Did you try it using an Android 4.x device attached with USB and using the Debug tab? Nothing about your code is XDK-specific. Was your network connection working when you performed the test?

Ginger G.'s picture

When run on the device, using debug it does nto work causing a Network Error.

Network connections was up

It just seems like the XMLHttpRequest does not work with Intel XDK at all :(. This is the app header:

<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="intelxdk.js"></script>
<script src="xhr.js"></script>
<meta http-equiv="Pragma" content="no-cache">
<script type="text/javascript" charset="utf-8" src="intelxdk.js"></script>
<script type="text/javascript" src="js/gingerlib.js"></script>
<script type="text/javascript" language="javascript">
    // This event handler is fired once the intel libraries are ready
    function onDeviceReady() {
        //hide splash screen now that our app is ready to run
        intel.xdk.device.hideSplashScreen();
        setTimeout(function () {
            $.ui.launch();
        }, 50);
    }
    //initial event handler to detect when intel is ready to roll
    document.addEventListener("intel.xdk.device.ready", onDeviceReady, false);
</script>
<script type="text/javascript" style="">

</script>
<script src="js/appframework.ui.min.js"></script>

<script>
    $.ui.autoLaunch = false;
    $.ui.useOSThemes = true; //Change this to false to force a device theme
    $.ui.blockPageScroll();
    $(document).ready(function () {
        //if ($.ui.useOSThemes && !$.os.ios && $("#afui").get(0).className !== "ios")
          //  $("#afui").removeClass("ios");
    });
</script>
<link href="css/icons.css" rel="stylesheet" type="text/css">
<link href="css/af.ui.css" rel="stylesheet" type="text/css">

That function was in gingerlib.js

Paul Fischer (Intel)'s picture

Put your code inside the onDeviceReady() function, otherwise it will run before the underlying XDK subsystem is ready.

Ginger G.'s picture

It is only intitiated on a user clicking a button, so it can't be before onDeviceReady().

Paul Fischer (Intel)'s picture

Your inclusion of gingerlib.js must contain code that is getting executed and causing the error before the underlying device and xdk JS files are ready. Turn your gingerlib.js file into definition code, only and put the init code inside of it into onDeviceReady().

Login to leave a comment.