我已经看过其他的例子,看起来我做的一切都很正确,但显然我错过了一些东西。在我的桌面上运行它运行良好。一旦通过PhoneGap Build捆绑到应用程序中,它就不再有效了:(想知道是否有人能发现原因。它真正做的就是从xml响应中挑选出独特的项目并列出它们。谢谢 麦克
<!DOCTYPE HTML>
<html>
<head>
<title>TestApp</title>
<script type = "text/javascript" charset = "utf-8" src = "cordova-2.3.0.js"></script>
<!-- Jquery stuff -->
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel="stylesheet" href="jquery/jquery.mobile-1.4.0.min.css" />
<script src="jquery/jquery-1.10.1.min.js"></script>
<script src="jquery/jquery.mobile-1.4.0.min.js"></script>
<script type = "text/javascript">
function onBodyLoad(){
//pre-loads data
loadXMLDoc('http://login.etherios.com/ws/DiaChannelDataFull');
}
function loadXMLDoc(url) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var lastXBee=0;
var adChannel=0;
txt="<table border='0' width='%100'><tr><th>title</th></tr>";
x=xmlhttp.responseXML.documentElement.getElementsByTagName("DiaChannelDataFull");
for (i=0;i<x.length;i++) {
xx=x[i].getElementsByTagName("ddInstanceName"); {
if (lastXBee!=xx[0].firstChild.nodeValue) { // if not a reading from same , start new row
try {
txt=txt + "<tr>";
txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er) {
txt=txt + "<tr>";
txt=txt + "<td> </td>";
}
var lastXBee=xx[0].firstChild.nodeValue;
var sameRow="No";
}
else {}
}
}
txt=txt + "</table><br />";
document.getElementById('currentStatus').innerHTML=txt;
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>
</head>
<body onload = "onBodyLoad()">
<h4>Current Status:</h4>
<!-- **** Call to getRequestList.js file *** -->
<button onclick="loadXMLDoc('http://login.etherios.com/ws/DiaChannelDataFull')">Refresh Sensor Data</button>
<div id="currentStatus"></div>
<br />
</body>
</html>
答案 0 :(得分:0)
我放弃了这一点,决定朝另一个方向前进。