async 属性

Definition and Usage
定义和用法

The async property specifies whether downloading of an XML file should be handled asynchronously or not.
async属性的作用是:指定XML文件的下载是否与XML的处理异步进行。

True means that the load() method returns the control to the caller before the download is complete.
这意味着load()方法必须在下载结束之前将控制指令返回给请求对象。

False means that the download must be completed before the caller gets the control back.
False意味着下载必须在请求对象取回控制指令之前完成。

Syntax
语法

documentObject.async


Example
案例

In nearly all our examples, we have used the books.xml file and the JavaScript function loadXMLDoc(). The loadXMLDoc() function uses the async property:
在我们的大部分案例中,我们都使用了“books.xml”文件以及JavaScript 函数“loadXMLDoc()”。“loadXMLDoc()” 函数使用的是async[异步]属性:

function loadXMLDoc(dname) 
{
var xmlDoc;
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
            xmlDoc.async=false;
xmlDoc.load(dname);
return(xmlDoc);
}

你可能感兴趣的:(async)