- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm creating an App that needs to send data up to a server and then retrieves data. Just getting the functions to work before I start to format and 'pretty it up'.
The POST functions fine and I capture with a php server that put into the database.
Using Ajax GET to retrieve the data, again from a php sender, and it works fine in the Emulator - but on App Preview it just crashes. Could anyone help please?
The JS function that is doing the GET and just displaying some of the data is as follows; (off the click of a button called 'butget'.
Like I say in the Emulator it displays the result, but on App Preview it just crashes the App Preview App.
<script type="text/javascript">
$(document).ready(function() {
$("#butget").click(function(){
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://myurl.testget.php?names=json", false);
xhr.onload = function(){
var gotdata;
if(xhr.status == 200)
{
gotdata = JSON.parse(xhr.responseText);
intel.xdk.notification.alert(gotdata.Name1, "Name 1");
}
else if(xhr.status == 404)
{
intel.xdk.notification.alert("Web Service Doesn't Exist", "Error");
}
else
{
intel.xdk.notification.alert("Unknown error occured while connecting to server", "Error");
}
}
xhr.send();
});
});
</script>
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does it also fail if you use the Debug tab? The Debug tab runs on device but gives you a better debugging environment. It can be used with an Android or iOS device. Please give it a try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Been testing on iOs but don't have a dev account with Apple yet, so borrowed wife's Samsung - and it works OK thru that using App Preview?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Got the debugging working on Android - but the code works...not sure what to look at.
It ALSO works fine on my Kindle (Android also)....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If this is an iOS-specific problem then you're either going to have to get yourself an Apple dev account so you can do USB-connected debugging, or use the Test tab with the weinre script, for very limited debugging (you can, at minimum, perform the AJAX call from the console using weinre and see what happens). See these doc pages for hints on how to use weinre:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok thanks, will get an account.
Are there ant more reliable ways to do what I want...any sample code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use real AJAX calls, not the old intel.xdk APIs, those have been deprecated and will be going away.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok Thanks - can you point me to any tutorials or sample code? I am quite new to this....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For standard HTML5 good places to look for info are the HTML5 Rocks site and W3 Schools site. Search for AJAX.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FYI - Just in case you weren't aware - there is no longer cost for Apple dev licenses (for testing only). That was announced at WWDC in June.
Correction:
Apple no longer requires a developer's license if you are only testing - that was announced at WWDC in June, though I haven't gone through the process myself. Supposedly you only need to sign in with your AppleID.
Here is the page that discusses Apple's free provisioning: Read under the heading "Launch Your App on Devices Using Free Provisioning"https://developer.apple.com/library/prerelease/ios/documentation/IDEs/Co...
Note: some capabilities are not available (but as far as I can see they are related to sales type functionality - so you would not be able to test things like In-App purchases).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Pamela.... Will look into that

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page