diff --git a/lib/wp7/plugin/wp7/XHRPatch.js b/lib/wp7/plugin/wp7/XHRPatch.js index 14a857522..a16c4ef3b 100644 --- a/lib/wp7/plugin/wp7/XHRPatch.js +++ b/lib/wp7/plugin/wp7/XHRPatch.js @@ -105,12 +105,18 @@ if (!docDomain || docDomain.length === 0) { return this.wrappedXHR.open(reqType, uri, isAsync, user, password); } else { + console.log("url is " + uri); // x-wmapp1://app/www/page2.html // need to work some magic on the actual url/filepath var newUrl = uri; if (newUrl.indexOf(":/") > -1) { newUrl = newUrl.split(":/")[1]; } + // prefix relative urls to our physical root + if(newUrl.indexOf("app/www/") < 0) + { + newUrl = "app/www/" + newUrl; + } if (newUrl.lastIndexOf("/") === newUrl.length - 1) { newUrl += "index.html"; // default page is index.html, when call is to a dir/ ( why not ...? ) @@ -140,6 +146,15 @@ if (!docDomain || docDomain.length === 0) { responseXML: "", onResult: function (res) { this.status = 200; + console.log("onResult XHR :: " + res); + console.log("typeof = " + typeof res); + if(typeof res == "object") + { // callback result handler may have already parsed this from a string-> a JSON object, + // if so, we need to restore it's stringyness, as handlers are expecting string data. + // especially if used with jQ -> $.getJSON + console.log("re-stringing the guitar"); + res = JSON.stringify(res); + } this.responseText = res; this.responseXML = res; this.changeReadyState(this.DONE);