1. Overview
XMLHttpRequest Level 2 is an enhancement to XMLHttpRequest and supports cross-origin.
2. browser support Detection
If (typeof xhr. withcredentials === undefined)
{
Document. getelementbyid ("support"). innerhtml =
"Your browser <strong> doesnot </strong> support cross-origin XMLHttpRequest ";
}
Else
{
Document. getelementbyid ("support"). innerhtml =
"Your browser <strong> does </strong> support cross-origin XMLHttpRequest ";
}
3. New event name
before XMLHttpRequest Level 2, the status of the XMLHttpRequest request and response is represented by numerical values, similar to enumeration. XMLHttpRequest Level 2 uses Named events to replace different statuses of requests and responses. These named events have corresponding event attributes and can assign event processing functions to the event attributes of each event.
the XMLHTTPRequest object has some events, such as loadstart, progress, abort, error, load, upload, and loaded. These events can be considered as sub-objects of XMLHttpRequest, and they have some event attributes.
XMLHttpRequest itself has some event attributes and events. XMLHttpRequest event attributes include XMLHttpRequest. onprograss, XMLHttpRequest. onload, and XMLHttpRequest. onerror.
You can input a parameter E in the Program function of event processing. E has some attributes related to events and data information, e. total, E. loaded, E. uploaded, E. downloaded, E. lengthcomputable.