×
Namespaces

Variants
Actions
(Difference between revisions)

Browser 7.3 XMLHttpRequest Issue (Known Issue)

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
(Forum Nokia KB -)
 
Forum Nokia KB (Talk | contribs)
m (Protected "KIC001676 - Browser 7.3 XMLHttpRequest Issue" ([edit=sysop] (indefinite) [move=sysop] (indefinite)))

Revision as of 15:10, 23 August 2011


Template:KBKI

Article Metadata
Tested with
Devices(s): All devices with Browser 7.3
Compatibility
Platform(s): Symbian^3, Symbian S60 5th Edition, Symbian S60 3rd Edition FP2
Article
Created: (23 Aug 2011)
Last edited: Forum Nokia KB (23 Aug 2011)

Description

When a Symbian Web Runtime widget, started from the Applications menu, is trying to access the internet for the first time, an 'Allow connection to Network?' prompt is shown. In previous browser versions, answering 'No' fires an onoffline event and XMLHttpRequest completes with status code 0. In Browser 7.3, denying network access fires an onoffline event, but XMLHttpRequest does not complete.

Solution

The solution is to implement a timer that aborts the XMLHttprequest if it is taking too long to complete. This will ensure that the request won’t be left hanging forever. Also, please note that usage of online/offline API is recommended in all WRT widgets.

var timeOutDelay = 10000; // 10 sec
var timerId;
 
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open("GET", "http://www.nokia.com", true);
 
xmlHttpRequest.onreadystatechange = function(){
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
clearTimeout(timerId);
alert(xmlHttpRequest.responseText);
}
}
xmlHttpRequest.send(null);
timerId = setTimeout(xmlHttpRequestOnTimeOut, timeOutDelay);
 
function xmlHttpRequestOnTimeOut(){
xmlHttpRequest.abort();
alert("XMLHttpRequest timed out");
}
90 page views in the last 30 days.
×