Ajax 请求在 Tizen 的模拟器中被取消,但在浏览器中没有
Ajax request Canceled in Tizen's emulator, but not in browser
当我尝试通过 $.getJSON
联系 webservice
时,我的 tizen 模拟器目前出现错误。
我有一个按钮,当我点击它时,我从 webservice
得到 JSON,就这么简单。在我的计算机浏览器上,这完美地工作,但是当我 运行 代码作为 Tizen 模拟器(齿轮)上的应用程序时,GET
方法 returns :(已取消)
Request cancelled
.
这是代码 (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 );
});
}
});
我可以在“网络”选项卡中看到取消错误,但控制台中没有显示任何内容。
我不知道问题出在 Tizen gear 模拟器中,代码在浏览器中运行完美。
谢谢。
编辑:这是我的 config.xml,互联网特权在这里。
<?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"/>
我从 Tizen 开发者论坛获得了解决方案。 config.xml
.
我没有设置上网权限和访问域
这是正确的文件:
<?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>
当我尝试通过 $.getJSON
联系 webservice
时,我的 tizen 模拟器目前出现错误。
我有一个按钮,当我点击它时,我从 webservice
得到 JSON,就这么简单。在我的计算机浏览器上,这完美地工作,但是当我 运行 代码作为 Tizen 模拟器(齿轮)上的应用程序时,GET
方法 returns :(已取消)
Request cancelled
.
这是代码 (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 );
});
}
});
我可以在“网络”选项卡中看到取消错误,但控制台中没有显示任何内容。 我不知道问题出在 Tizen gear 模拟器中,代码在浏览器中运行完美。
谢谢。
编辑:这是我的 config.xml,互联网特权在这里。
<?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"/>
我从 Tizen 开发者论坛获得了解决方案。 config.xml
.
这是正确的文件:
<?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>