I currently have an error with my tizen emulator when I try to contact a webservice
through $.getJSON
.
I have a button, when I click on it, I get the JSON from a webservice
, simple as that. On my computer browser, this works perfectly, but when I run the code as an app on Tizen's emulator (gear), the GET
method returns : (canceled)
Request cancelled
.
Here's the code (main.js):
$(window).load(function(){document.addEventListener('tizenhwkey', function(e) {
if(e.keyName == "back")
tizen.application.getCurrentApplication().exit();
});
$('.button').click(function(){
callWebService();//Calls webservice
return false;
});
function callWebService(){
//Works on desktop's Chrome
$.getJSON( "https://www.googleapis.com/freebase/v1/text/en/bob_dylan", function( data ) {
$('#ol_home_products').html(data.result);
})
.fail(function( err ) {
//Never called
console.log( err );
});
}
});
I can see the cancel error in Networks's tab, but nothing shows up in Console. I don't know where the problem is in Tizen gear emulator, the code works perfectly in browser.
Thanks.
EDIT : This is my config.xml, the privilege internet is here.
<?xml version="1.0" encoding="UTF-8"?><widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/myApp" version="1.0.0" viewmodes="maximized">
<tizen:application id="jVqvRz7h1V.myApp" package="jVqvRz7h1V" required_version="2.2"/>
<content src="index.html"/>
<feature name="http://tizen.org/feature/screen.size.all"/>
<icon src="icon.png"/>
<name>myApp</name>
<tizen:privilege name="http://tizen.org/privilege/internet"/>
I got the solution from Tizen developers' forums. I didn't set the Internet privilege and the access domain in config.xml
.
Here's the correct file :
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/myApp" version="1.0.0" viewmodes="maximized">
<tizen:application id="jVqvRz7h1V.myApp" package="jVqvRz7h1V" required_version="2.2"/>
<access origin="*" subdomains="true"/>
<content src="index.html"/>
<feature name="http://tizen.org/feature/screen.size.all"/>
<icon src="icon.png"/>
<name>myApp</name>
<tizen:privilege name="http://tizen.org/privilege/internet"/>
</widget>