Issue Details (XML | Word | Printable)

Key: DOL-125
Type: Bug Bug
Status: Reopened Reopened
Priority: Major Major
Assignee: Dierk Koenig
Reporter: Janak Mulani
Votes: 0
Watchers: 1

If you were logged in you would be able to see more operations.

OpenDolphin.JS's onloadend is not invoked in PhoneGap/Cordova environment.

Created: 21/Jul/14 07:10 AM   Updated: 28/Jul/14 11:19 AM
Component/s: dolphin.js
Affects Version/s: None
Fix Version/s: None
Security Level: public

Time Tracking:
Not Specified

Environment: PhoneGap/Cordova

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Janak Mulani added a comment - 21/Jul/14 07:13 AM
While trying to convert an OpenDolphin.JS based app to Android mobile app using PhoneGap/Cordova it was found that onloadend is not invoked after the XMLHttpRequest. It seems that onreadystatechange has to be used instead.

Kunal Singh added a comment - 25/Jul/14 12:52 PM - edited
Fixed with GIT commit: 6bf5516370aec9667fc80351cbe5b59fc84c797b
Changed in HttpTransmitter- onloadend reaplaced with onreadystatechanged
this.http.onreadystatechange= (evt:ProgressEvent) => {
                if (this.http.readyState==4 && this.http.status==200)
                    var responseText = this.http.responseText;
                    var responseCommands = this.codec.decode(responseText);

Dierk Koenig added a comment - 25/Jul/14 01:05 PM
We should not use magic literals (4 and 200) but meaningful constants.

Checking for status==OK may be too restrictive.
Is anything below 300 or even below 400 ok?

The onError logic must be called when the state has changed to 4 but the status is not ok.

Please add git commit hash to jira comment when closing an issue.

Kunal Singh added a comment - 28/Jul/14 08:24 AM - edited
Fixed with commit f855492ec0405d693d48e03c4f2cc97f04866081
For HttpStatus we can create constants like-
HttpCodes = {
            finished: 4,
            success : 200

and we can check

this.http.onreadystatechange= (evt:ProgressEvent) => {
                if (this.http.readyState == this.HttpCodes.finished){

                    if(this.http.status == this.HttpCodes.success)
                        var responseText = this.http.responseText;
                        var responseCommands = this.codec.decode(responseText);
                         //onerror should be called-- how to pass ErrorEvent here

How to get ErrorEvent in else part of onreadystatechange? Or we can directly give an alert there?

Do we need to concern about other than 200 status? I have no idea what to do with other codes below 300 or 400.