2016-01-13 69 views
0

这段代码是我的应用程序的一部分,在tizen设备上无法正常工作,但它在tizen模拟器上正常工作...任何人都可以看看并告诉我为什么!如果这是应答器表单或dom解析器的问题!任何人都可以告诉我如何解决它?在tizen设备上开发

THX

<!DOCTYPE html> 
 

 
<head> 
 
              
 

 
</head> 
 
<body> 
 
<div id="result"> 
 
</div> 
 
<div align="center"> 
 
<form name="myForm"> 
 

 
<button type="submit">go</button> 
 
</form> 
 
</div> 
 

 
<script> 
 
    //var doc; 
 
\t var xhr = new XMLHttpRequest(); 
 
\t xhr.open('GET', 'http://www.sntri.com.tn/html_ar/result_tarif_horaire_sntri.php', true); 
 
\t //xhr.setRequestHeader('Origin', 'www.sntri.com.tn'); 
 
\t //xhr.setRequestHeader('Allow-Control-Allow-Origin', '*'); 
 
\t xhr.send(); 
 
\t xhr.onreadystatechange = function() { 
 
\t \t if(4 === xhr.readyState) { 
 
\t \t \t if(200 === xhr.status) { 
 
\t \t \t \t var parser = new DOMParser(); 
 
\t \t \t \t var doc = parser.parseFromString(xhr.responseText, 'text/html'); 
 
\t \t \t \t var myForm = document.forms.myForm; 
 
\t \t \t \t //console.log(doc); 
 
\t \t \t \t var selectDep = doc.getElementsByName('code_arret_dep')[0]; 
 
\t \t \t \t var selectArr = doc.getElementsByName('code_arret_arr')[0]; 
 
\t \t \t \t doc.getElementBy 
 
\t \t \t \t //console.log(select); \t 
 
\t \t \t \t myForm.appendChild(selectDep); \t 
 
\t \t \t \t myForm.appendChild(selectArr); 
 
\t \t \t \t //console.log(xhr.responseText); 
 
\t 
 
\t \t \t \t myForm.onsubmit = function(e) { 
 
\t \t \t \t \t e.preventDefault(); 
 
\t \t \t \t \t var xhr = new XMLHttpRequest(); 
 
\t \t \t \t \t xhr.open('POST', 'http://www.sntri.com.tn/html_ar/result_tarif_horaire_sntri.php', true); 
 
\t \t \t \t \t xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
 
\t \t \t \t \t xhr.send('code_arret_dep='+selectDep.value+'&code_arret_arr='+selectArr.value); 
 
\t \t \t \t \t 
 
\t \t \t \t \t xhr.onreadystatechange = function() { 
 
\t \t \t \t \t \t if(4 === xhr.readyState) { 
 
\t \t \t \t \t \t \t if(200 === xhr.status) { 
 
\t \t \t \t \t \t \t \t var parser = new DOMParser(); 
 
\t \t \t \t \t \t \t \t var doc = parser.parseFromString(xhr.responseText, 'text/html'); 
 
\t \t \t \t \t \t \t \t var result = document.getElementById('result'); 
 
\t \t \t \t \t \t \t \t var tablex = doc.getElementById('tablex'); 
 
\t \t \t \t \t \t \t \t //console.log(doc); 
 
\t \t \t \t \t \t \t \t result.appendChild(tablex); 
 
\t \t \t \t \t \t \t \t //console.log(xhr.responseText); 
 
\t \t \t \t \t \t \t } 
 
\t \t \t \t \t \t } 
 
\t \t \t \t \t } 
 
\t \t \t \t \t 
 
\t \t \t \t \t console.log(selectDep.value); 
 
\t \t \t \t \t console.log(selectArr.value); 
 
\t \t \t \t } 
 
\t \t \t } 
 
\t \t } 
 
\t }; 
 
</script> 
 
</body>

+0

[Tizen + DOM解析器(的可能的复制http://stackoverflow.com/questions/34748412/tizen-dom-parser) – rmjoia

回答

0

你添加Internet的权限? 您可以在config.xml中添加权限。

  1. 打开Tizen IDE上的config.xml。
  2. 选择特权点击。
  3. 点击“添加”按钮。
  4. 选择http://tizen.org/privilege/internet
  5. 运行您的应用程序。
+0

是的,我已经添加了它,但它不能在设备上工作 –

+0

你能再次使用“”吗?这也增加了config.xml。 –

+0

是的,我已添加它!我不知道为什么模拟器中的应答器表格显示,但在设备号中:/ –

0

在tizen 2.4版本6上,我发现我需要在config> policy中明确设置URL。更普遍的'互联网'特权不存在。

  1. 创建带有IDE
  2. 轮廓电视三星公开的个人资料项目设置的配置/政策,您打算连接到的URL。在这种情况下http://www.sntri.com.tn

enter image description here

你的config.xml源现在应该包括线

<access origin="http://www.sntri.com.tn" subdomains="true"/>