Software Archive
Read-only legacy content
17060 Discussions

Disable network in XDK emulation

David_S_1
Beginner
607 Views

Hi,

Related to my previous (first) post http://software.intel.com/en-us/forums/topic/505367

I would like to implement a simple network detection script (to advise the user they need to be connected), by using an ajax call to an external web server. On success it fires an alert with the contents of the file fetched by the call; on fail (error) it is supposed to show an alert to that effect.

    function testNet(data){
		$.ajax({
			type:"GET",
			url:'[myurl]/networktest.txt',
			//data:{'net':'fetched'},
			success:isNet,
			error:noNet
		});
	}
	function isNet(data) {
		alert(data);
	}
	function noNet() {
		alert('no network');
	}
	testNet();

The ajax call works (it gets the file and displays contents), but I can't seem to disable the network in XDK emulation mode, by setting Connection Type to "none" under "Device & Network Settings" tab -- it still fetches the file from the remote server, so error: doesn't get called (not to mention, the fonts and images load from the server per usual!).

Any advice on how I can test the function?

Thanks

0 Kudos
3 Replies
PaulF_IntelCorp
Employee
607 Views

Did you try using App Preview and the Test tab to test this?

0 Kudos
David_S_1
Beginner
607 Views

Hi Paul,

If my device is not connected to the network (wifi off), App Preview doesn't work anyway. I've worked out a different way of testing the function by renaming the file on the server, and that sort of works (inconsistently). However, when I build an Android app it appears the script is not running. I suspect this may be a js library issue. I added -

[javascript]<script src="js/appframework.min.js" type="text/javascript"></script>
<script src="xhr.js"></script>
<script src="intelxdk.js"></script>[/javascript]

- to index.html, in order to get it working in App Preview. Do I need to add jquery as well?

Would it be possible for you to take a look at my project if I email it to you (it's only about 28K zipped, with 18 lines of code in main.js)?

I can send you a link to the Android build, but since the function isn't working, I don't know what that will tell you.

Thanks,

David

0 Kudos
PaulF_IntelCorp
Employee
607 Views

Hello David,

Use the "Send Author a Message" (or something like that) to create a private message on this thread. From there you can attach a file to the message which I, or my colleagues, can download. I'm not exactly sure how this looks for you, since I think we will have different views and I don't have a lot of practice on this new forum, most of our support activity is located on the old forum, here:

https://forums.html5dev-software.intel.com/

In fact, at this time, your posts will be responded to more quickly at the forum above.

Paul

0 Kudos
Reply