- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I developed a HTML5 app in XDK reading from a local XML file. In the emulator it works properly, and built on android app as well, but the test does not work ios.
access to the XML file is done with a call:
Connect var = new XMLHttpRequest ();
Connect.open ("GET", "data /archivename.xml file", false);
Connect.setRequestHeader ("Content-Type", "text / xml");
Connect.send (null);
What is the problem?
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Under the "Build Settings" you will find a section named "Domain List" where you can enter the domains you wish to provide access to (or use * or all domains). Can you check that?
Which XDK version are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@pedrovi, On the device the relative path will not work. You have to get the path of the folder where you app resides. To get the webroot use this function and then attache your relative path to it to access the file.
function getWebRoot() { "use strict" ; var path = window.location.href ; path = path.substring( 0, path.lastIndexOf('/') ) ; return path ; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have changed the relative path with your function, but the result is the same. In the emulate works fine, the same in the debug on android device (intel preview), but in the ios app preview doesn´t work. This is the code:
function getWebRoot() {
"use strict" ;
var path = window.location.href ;
path = path.substring( 0, path.lastIndexOf('/') ) ;
return path ;
}
//Read xml file
var Connect = new XMLHttpRequest();
var FileName = getWebRoot() + "/file.xml";
Connect.open("GET", FileName, false);
I have Intel XDK 2496 version on Mac
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There have been users who have faced this issue trying to access media files on device. Here is a detailed answer to locating the application's root directory on different platforms: http://stackoverflow.com/questions/21321335/intel-xdk-directory-browsing/21392617#21392617
Users have found this method useful. If it doesn't solve your issue, please post back. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There have been users who have faced this issue trying to access media files on device. Here is a detailed answer to locating the application's root directory on different platforms: http://stackoverflow.com/questions/21321335/intel-xdk-directory-browsing...
Users have found this method useful. If it doesn't solve your issue, please post back. Thanks!
I have same problem and it doesn's solve this issue. Can you give us some advice?
My config:
http://pictub.club/image/V2clY
My code:
function getWebRoot() { "use strict" ; var path = window.location.href ; path = path.substring( 0, path.lastIndexOf('/') ) ; return path ; } function loadText(url,callback) { alert(getWebRoot()+"/" +url); var xhr = new XMLHttpRequest(); xhr.responseType = 'text'; xhr.onreadystatechange = function() { if (xhr.readyState == 4) { //Request is complete if(xhr.state == 200) { //Response is ready alert("Request succeeded. Data: "+xhr.responseText); callback(null, xhr.response); } else { //Error handler alert('Request failed with error code: ' + xhr.state); callback(xhr.response, null); } } } xhr.open("GET", getWebRoot() +"/"+url,true); xhr.send(null); }
I got error 'Request failed with error code: undefined'...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See this FAQ > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail < it might have some clues. You may also need to check for a return code of 0, not just 200.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I fix this issue by change the extension .json to .txt.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Paul F. (Intel) wrote:
See this FAQ > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail < it might have some clues. You may also need to check for a return code of 0, not just 200.
I think it's a bug on iOS. If we request to a json file first, the request always fail with undefined code return.
Note: After I change the extension of the first url request from json to txt and it work; all latter request work with json url.
Sorry for my bad English
Thanks
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page