1.概述
xmlhttprequest level 2是对xmlhttprequest增强,具有cross-origin支持性。
2.浏览器支持性检测
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.新的事件名称
在XMLHttpRequest Level 2之前,XMLHttpRequest请求与响应的状态使用一些数值进行表示,类似于枚举。XMLHttpRequest Level 2使用命名的事件代替请求与响应的不同状态,这些命名事件具有相应的事件属性,可以将事件处理函数赋予各事件的事件属性。
XMLHttpRequest对象有一些事件,如:loadstart, progress, abort, error, load, upload, loaded等。
这些事件可以看作XMLHttpRequest的子对象,并且它们有一些事件属性,
XMLHttpRequest本身具有一些事件属性和事件。XMLHttpRequest事件属性有XMLHttpRequest.onprograss, XMLHttpRequest.onload, XMLHttpRequest.onerror等。
可以在事件处理程序函数中传入一个参数e,e具有一些与事件和数据信息相关的属性,比如:e.total, e.loaded, e.uploaded, e.downloaded, e.lengthComputable等。
以上就是HTML5-XMLHttpRequest Level 2概述详解的详细内容,更多请关注php中文网其它相关文章!
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号