<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic The &amp;quot;emulator&amp;quot; is just a in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039298#M45343</link>
    <description>&lt;P&gt;The "emulator" is just a variant of the Chromium browse. App Preview runs you code in the embedded webview on that device. The behaviors will not match. See this blog for a little background: &lt;A href="http://blogs.intel.com/evangelists/2014/09/02/html5-web-app-webview-app/" target="_blank"&gt;http://blogs.intel.com/evangelists/2014/09/02/html5-web-app-webview-app/&lt;/A&gt; -- the Emulate tab is useful for quick debug of the logic in your program, but for real testing and debug you need to use a real device.&lt;/P&gt;

&lt;P&gt;What doesn't make sense is that typing "var x = new FormData()" on the console gives you a "can't find variable x" message. You should get "undefined" if the "FormData()" function does nothing, does not exist or returns nothing. The "can't find variable x" points to not using the "var" modifier to make sure the variable exists.&lt;/P&gt;

&lt;P&gt;BTW -- &lt;CODE class="plain"&gt;intel.xdk.device.osversion&lt;/CODE&gt; and other "intel.xdk" namespace methods and properties only exist on a real device if you have included the appropriate xdk plugin. Otherwise they will cause your code to stop if you reference those items without including the appropriate plugin. In general, we recommend you not use them, as they have been deprecated. That could the source of the problem you are having.&lt;/P&gt;

&lt;P&gt;Another way to get that information without using the intel.xdk namespace is to include the Cordova device plugin and use this code:&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;    if( window.device &amp;amp;&amp;amp; device.cordova ) {                             // old Cordova 2.x version detection
        console.log("device.cordova: "  + device.cordova) ;          // print the cordova version string...
        console.log("device.model: "    + device.model) ;            // on Cordova 3.0+ these require that
        console.log("device.platform: " + device.platform) ;         // the Cordova Device plugin is installed
        console.log("device.version: "  + device.version) ;          // if not, they will not exist
    }

&lt;/PRE&gt;

&lt;P&gt;"device.version" will give you the OS version number for the platform and "device.platform" will tell you if it is Android, iOS, etc.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Aug 2015 18:30:00 GMT</pubDate>
    <dc:creator>PaulF_IntelCorp</dc:creator>
    <dc:date>2015-08-05T18:30:00Z</dc:date>
    <item>
      <title>App breaks when initializing FormData Object</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039291#M45336</link>
      <description>&lt;P&gt;&amp;nbsp;Hello!&lt;/P&gt;

&lt;P&gt;My colleague and I switched to POST request recently. That isn't the problem, it works really fine, but now there is a problem which I can't solve. In the Emulator and if I debug the app on a device while it is connected with the computer, all works fine. But if I test the app in the App Previewer, the app breaks on the line where I initialize the FormData JS object. That's strange, because, as far as I remember, it worked already with one test POST request, but now it seems not to work at all. Here's the script snippet where the request would be send. I really don't know how to solve that problem, and we don't really want to go back to GET.&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;var xhr = new XMLHttpRequest();

    _USER = document.getElementById("username").value;
    var pass = md5(document.getElementById("password").value);
    xhr.open("POST", _URL + "app_login.php", false);
    
    var formData = new FormData();
    formData.append("user", _USER);
    formData.append("pass", pass);
    formData.append("os", intel.xdk.device.platform);
    formData.append("os_ver", intel.xdk.device.osversion);
    
    xhr.send(formData);

    responselogin = JSON.parse(xhr.responseText);
    if (responselogin != 99) {
        session = true;
        _UID = responselogin[0].user;
        initProjectspage();
    } else {
        session = false;
    }  &lt;/PRE&gt;

&lt;P&gt;I'm sure there is a solution for that problem. And by the way, why do Apple devices response with null if calling intel.xdk.device.platform or osversion? Its not a problem, I'm just interested in.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2015 07:54:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039291#M45336</guid>
      <dc:creator>Patrick_C_1</dc:creator>
      <dc:date>2015-08-04T07:54:51Z</dc:date>
    </item>
    <item>
      <title>Are you sure it is failing on</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039292#M45337</link>
      <description>&lt;P&gt;Are you sure it is failing on new FormData() ?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;If I had to guess, I would imagine it is failing on&amp;nbsp;&lt;SPAN style="color: rgb(0, 0, 0); font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 13.008px; line-height: 14.3088px;"&gt;responselogin = JSON.parse(xhr.responseText); &amp;nbsp; If I remember correctly, the response won't be on the xhr object. Or, if it is, asynchronously, not until the response is received.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;xhr.onreadystatechange = function () {

    if (xhr.readyState === 4) {

      console.log(xhr.response);
   }
}&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2015 16:28:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039292#M45337</guid>
      <dc:creator>Chris_P_Intel</dc:creator>
      <dc:date>2015-08-04T16:28:29Z</dc:date>
    </item>
    <item>
      <title>Yes, I'm pretty sure it is</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039293#M45338</link>
      <description>&lt;P&gt;Yes, I'm pretty sure it is failing on new FormData(), because when I add a console widget to the login page and add a console.log() before and after all the FormData stuff, I only get the one before the new FormData(). And the request is right, because at w3schools is a example, where the xhr.responseText is also get after send (synchronously). I also tried to run the request asynchronously, but I get the same result - it stops before the new FormData().&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 06:44:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039293#M45338</guid>
      <dc:creator>Patrick_C_1</dc:creator>
      <dc:date>2015-08-05T06:44:54Z</dc:date>
    </item>
    <item>
      <title>If you are using the console</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039294#M45339</link>
      <description>&lt;P&gt;If you are using the console widget, then you can type &amp;nbsp; var x = new FormData() right in the console and then evaluate x. &amp;nbsp;Take a look.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 16:39:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039294#M45339</guid>
      <dc:creator>Chris_P_Intel</dc:creator>
      <dc:date>2015-08-05T16:39:56Z</dc:date>
    </item>
    <item>
      <title>If I do this, I get following</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039295#M45340</link>
      <description>&lt;P&gt;If I do this, I get following message:&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;ReferenceError: Can't find variable: x&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 17:40:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039295#M45340</guid>
      <dc:creator>Patrick_C_1</dc:creator>
      <dc:date>2015-08-05T17:40:34Z</dc:date>
    </item>
    <item>
      <title>did you include the "var" in</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039296#M45341</link>
      <description>&lt;P&gt;did you include the "var" in front of the "x"?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 18:07:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039296#M45341</guid>
      <dc:creator>PaulF_IntelCorp</dc:creator>
      <dc:date>2015-08-05T18:07:01Z</dc:date>
    </item>
    <item>
      <title>Yes. I've also tried it in</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039297#M45342</link>
      <description>&lt;P&gt;Yes. I've also tried it in the Emulator - which is certainly unnecessary, but the strange thing is, that in the emulator I get back, that x is not defined, in opposite to the App Previewer on my phone, where I get back, that x can't be found.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 18:09:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039297#M45342</guid>
      <dc:creator>Patrick_C_1</dc:creator>
      <dc:date>2015-08-05T18:09:33Z</dc:date>
    </item>
    <item>
      <title>The "emulator" is just a</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039298#M45343</link>
      <description>&lt;P&gt;The "emulator" is just a variant of the Chromium browse. App Preview runs you code in the embedded webview on that device. The behaviors will not match. See this blog for a little background: &lt;A href="http://blogs.intel.com/evangelists/2014/09/02/html5-web-app-webview-app/" target="_blank"&gt;http://blogs.intel.com/evangelists/2014/09/02/html5-web-app-webview-app/&lt;/A&gt; -- the Emulate tab is useful for quick debug of the logic in your program, but for real testing and debug you need to use a real device.&lt;/P&gt;

&lt;P&gt;What doesn't make sense is that typing "var x = new FormData()" on the console gives you a "can't find variable x" message. You should get "undefined" if the "FormData()" function does nothing, does not exist or returns nothing. The "can't find variable x" points to not using the "var" modifier to make sure the variable exists.&lt;/P&gt;

&lt;P&gt;BTW -- &lt;CODE class="plain"&gt;intel.xdk.device.osversion&lt;/CODE&gt; and other "intel.xdk" namespace methods and properties only exist on a real device if you have included the appropriate xdk plugin. Otherwise they will cause your code to stop if you reference those items without including the appropriate plugin. In general, we recommend you not use them, as they have been deprecated. That could the source of the problem you are having.&lt;/P&gt;

&lt;P&gt;Another way to get that information without using the intel.xdk namespace is to include the Cordova device plugin and use this code:&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;    if( window.device &amp;amp;&amp;amp; device.cordova ) {                             // old Cordova 2.x version detection
        console.log("device.cordova: "  + device.cordova) ;          // print the cordova version string...
        console.log("device.model: "    + device.model) ;            // on Cordova 3.0+ these require that
        console.log("device.platform: " + device.platform) ;         // the Cordova Device plugin is installed
        console.log("device.version: "  + device.version) ;          // if not, they will not exist
    }

&lt;/PRE&gt;

&lt;P&gt;"device.version" will give you the OS version number for the platform and "device.platform" will tell you if it is Android, iOS, etc.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 18:30:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039298#M45343</guid>
      <dc:creator>PaulF_IntelCorp</dc:creator>
      <dc:date>2015-08-05T18:30:00Z</dc:date>
    </item>
    <item>
      <title>Thank you so much, that is</title>
      <link>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039299#M45344</link>
      <description>&lt;P&gt;Thank you so much, that is the solution for my problem. Never thought of that, I even didn't know that the intel.xdk.device is outdated, but learning never stops.&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 18:42:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/App-breaks-when-initializing-FormData-Object/m-p/1039299#M45344</guid>
      <dc:creator>Patrick_C_1</dc:creator>
      <dc:date>2015-08-05T18:42:01Z</dc:date>
    </item>
  </channel>
</rss>

