×
Namespaces

Variants
Actions
(Difference between revisions)

Browser 7.3 XMLHttpRequest Issue (Known Issue)

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
lpvalente (Talk | contribs)
m (Lpvalente -)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 +
[[Category:Known Issue]][[Category:Browser]][[Category:Symbian Web Runtime]]
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
+
|devices= All devices with Browser 7.3
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
+
|platform= Symbian^3, Symbian S60 5th Edition, Symbian S60 3rd Edition FP2
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
Line 20: Line 21:
 
|creationdate= 20110823
 
|creationdate= 20110823
 
|author= [[User:Nokia Developer KB]]
 
|author= [[User:Nokia Developer KB]]
}}
 
{{KnowledgeBase
 
 
|id=KIC001676
 
|id=KIC001676
|platform= Symbian^3, Symbian S60 5th Edition, Symbian S60 3rd Edition FP2
 
|devices= All devices with Browser 7.3
 
|category= WRT
 
|subcategory=
 
|creationdate= August 23, 2011
 
|keywords=
 
 
}}
 
}}
 +
 
== Description ==
 
== 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.  
+
{{Abstract|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 ==
 
== 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.  
 
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.  
Line 55: Line 50:
 
}
 
}
 
</code>
 
</code>
[[Category:Known Issue]]
 
[[Category:Browser]]
 
[[Category:Symbian Web Runtime]]
 

Latest revision as of 16:04, 16 June 2012

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: User:Nokia Developer KB (23 Aug 2011)
Last edited: lpvalente (16 Jun 2012)

[edit] 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.

[edit] 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");
}
This page was last modified on 16 June 2012, at 16:04.
113 page views in the last 30 days.