I'm Developing an windows store apps using javascript. I have deployed WCF service and able get data from the wcf service.My problem is the data is unable to bind to controls(here i'm having only one dropdown box).
<body onload="onLoad()">
<select id="CbxArea" style="width: 200px" data-win-bind="textContent: AreaName">
<option>Select Area</option>
</select>
<script type="text/javascript">
function onLoad() {
var xmlhttp;
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 Items = JSON.parse(xmlhttp.responseText);<--Frist Way
var Items = window.toStaticHTML(xmlhttp.responseText);<--Second Way
for(var i=0;i<Items.length;i++)
{
document.getElementById('CbxArea').innerHTML = '<option>' + Items+'</option>';
}
}
else {
document.getElementById('CbxArea').innerHTML = '<option>' + 'Error' + '</option>';
}
}
xmlhttp.open("POST", "WCFService_url", true);
xmlhttp.send();
}
</script>
</body>
i have tried using json.parse and windows.toStaticHTML but i'm unable to bind the data to dropdown. Please any provide me any solution is much appreciated.