You are here: Reference > JavaScript > client-side > event handling > properties > reason (event)

reason property (event)

Browser support:
Sets or retrieves an integer value that indicates whether the data transfer was successful or not. Use this property with ondatasetcomplete events.

Syntax:

object.reason;
You can find the related objects in the Supported by objects section below.
This property is read/write.

Possible values:

Integer that specifies or retrieves the transfer state.
One of the following values:
0
Transfer is successful.
1
Transfer has aborted.
2
Some error has occurred during data transfer.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the reason property:
Code
news.xml
<head>
    <script type="text/javascript">
        function HandleData () {
            switch (event.reason) {
            case 0:
                alert ("Transfer is successful.");
                if (event.qualifier == "") {
                    alert ("No default data member is specified.");
                }
                else {
                    alert ("The name of the default data member is: " + event.qualifier);
                }
                break;
            case 1:
                alert ("Transfer has aborted.");
                break;
            case 2:
                alert ("Some error has occurred during data transfer.");
                break;
            }
        }
    </script> 
</head>
<body>
    <xml src="news.xml" ondatasetcomplete="HandleData ();"></xml>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content