My code is:
var userName = document.getElementById("txtSearch").value;
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://www.rest.net/services/abc.svc/json/GetXml", true);
xhr.responseType = "text";
xhr.setRequestHeader("Content-Type", "text/xml;charset=UTF-8");
var packet = '<?xml version="1.0" encoding="utf-8" ?><CompanyRequest xmlns="http://schemas.datacontract.org/2004/07/abc.DomainModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><CompanyName>company</CompanyName></CompanyRequest>';
xhr.onreadystatechange = function () {
if (xhr.readyState==xhr.DONE) {
var parser = new DOMParser();
var response = parser.parseFromString( xhr.responseText, "text/xml");
var n = response.getElementsByTagName("CompanyResponse");
for (var i = 0; i < n.length; i++) {
var p = n[i].getElementsByTagName("CompanyList1");
for (var j = 0; j < p.length; j++) {
var l = p[j].getElementsByTagName("Company");
for (var k = 0; k < l.length; k++) {
var a = l[k].getElementsByTagName("Id")[0].firstChild.nodeValue;
if (a != null) {
sessionStorage.setItem(1, a);
WinJS.Navigation.navigate("Search.html");
}
}
}
}
}
}
xhr.send(packet);
I am very new to this. I want to navigate to search.html page on button click. But it is not going so…what’s wrong with it i cant understand…help me..
Thanks in advance……….
If you are using the Navigation Template from visual studio, then you need to:
The WinJS.Navigation namespace is not intended for navigating the application to internet-urls; it’s intended to manage navigation within the application e.g. files already in your package.
If your trying to navigate the whole application, you can set window.location.href to the full URL you wish to navigate to. This will tear down your current script state and move you wholesale to that page.
If you really are using single page navigation, I suggest stepping into the navigate call you have, and seeing where it leads you to verify you’ve correctly registered the destination & the Navigation Template sample code is doing it’s work.