I have a widget that is added to the homescreen. The widget has a fullscreen view in which you can check for new versions of the widget. It does an async. XMLHttpRequest to connect to my webserver in order to fetch the current version info.
This all works fine (I've added the required permission to Info.plist). However the connection is never closed. Either the wireless or the gsm network connection icon will always be visible after doing a new version check. As soon as I remove the widget from the homescreen again, the connection is properly closed down.
How can I tell the phone to close the connection it opened for my widget?
My code looks like this:
Code:var reqV = null; function checkForUpdate() { // asynch XHR to server url reqV = new XMLHttpRequest(); reqV.onreadystatechange = checkForUpdateCallback; document.getElementById("updateDiv").innerHTML = getLocalizedText("update.checking"); reqV.open("GET", versionURL, true); reqV.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" ); // disable caching reqV.send(null); } function checkForUpdateCallback() { if (reqV.readyState == 4) { if (reqV.status == 200) { var resultXml = reqV.responseText; if (resultXml) { var div = document.getElementById("tmp"); div.innerHTML = resultXml; var newVersion = div.getElementsByTagName('version')[0].innerHTML; var newVersionURL = div.getElementsByTagName('url')[0].innerHTML; div.innerHTML = ""; if (version != newVersion) { document.getElementById("updateDiv").innerHTML = getLocalizedText("update.download").replace(/%1/, newVersion).replace(/%2/, newVersionURL); } else { document.getElementById("updateDiv").innerHTML = getLocalizedText("update.nonewversion"); } } } else { document.getElementById("updateDiv").innerHTML = getLocalizedText("update.error") + reqV.status + " " + reqV.responseText + ", " + getAllResponseHeaders(); } } else document.getElementById("updateDiv").innerHTML = getLocalizedText("update.error") + reqV.readyState + ", " + reqV.status + " " + reqV.responseText + ", " + getAllResponseHeaders(); delete reqV; reqV = null; }

Reply With Quote

