过完年了,回单位上班了,总结一下ajax加载文档的生命周期

作者利用春节假期休息之余,购买了一些软件书籍,并决定深入研究Ajax技术。通过学习,初步了解了Ajax加载文档的生命周期,发现不同浏览器对文档加载的显示过程虽有所不同,但最终结果一致。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

过年放假差不多半个月,在家呆着好舒服,真是有点不想回来,回来又要面对新一年的工作,自己想想又要拼搏一年了。感觉自己肩上的责任比去年大多了。
到五一钱可能不用出差了,感慨一下:终于可以过正常人的生活了!
过年没给自己买什么,买了点关于软件的书,先研究ajax吧。

先总结一下自己假期学的:关于ajax加载文档的生命周期。
我们可以从这个程序中看出,不同浏览器对加载文档的输出不一样,但是最后的结果却是一样。
None.gif<html>
None.gif
<head>
ExpandedBlockStart.gifContractedBlock.gif
<script type='text/javascript'>dot.gif
InBlock.gif
var req=null;
InBlock.gif
var console=null;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function sendRequest(url,params,HttpMethod)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(!HttpMethod)dot.gif{
InBlock.gifHttpMethod
="GET";
ExpandedSubBlockEnd.gif}

InBlock.gifreq
=initXMLHTTPRequest();
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(req)dot.gif{
InBlock.gifreq.onreadystatechange
=onReadyState;
InBlock.gifreq.open(HttpMethod,url,
true);
InBlock.gif
//req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
InBlock.gif
req.send(params);
ExpandedSubBlockEnd.gif}

ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function initXMLHTTPRequest()dot.gif{
InBlock.gif
var xRequest=null;
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(window.XMLHttpRequest)dot.gif{
InBlock.gifxRequest
=new XMLHttpRequest();
ExpandedSubBlockStart.gifContractedSubBlock.gif}
 else if(window.ActiveXObject)dot.gif{
InBlock.gifxRequest 
= new ActiveXObject("Microsoft.XMLHTTP");
ExpandedSubBlockEnd.gif}

InBlock.gif
return xRequest;
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function onReadyState()dot.gif{
InBlock.gif
var ready=req.readyState;
InBlock.gif
var data=null;
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(ready==4)dot.gif{
InBlock.gifdata.responseText;
ExpandedSubBlockStart.gifContractedSubBlock.gif}
elsedot.gif{
InBlock.gifdata
="loading dot.gif["+ready+"]";
ExpandedSubBlockEnd.gif}

InBlock.giftoconsole(data);
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function toconsole(data)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(console!=null)dot.gif{
InBlock.gif
var newline=document.createElement("div");
InBlock.gifconsole.appendChild(newline);
InBlock.gif
var txt=document.createTextNode(data);
InBlock.gifnewline.appendChild(txt);
ExpandedSubBlockEnd.gif}

ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gifwindow.onload
=function()dot.gif{
InBlock.gifconsole
=document.getElementById('console');
InBlock.gifsendRequest(
"data.txt");
ExpandedBlockEnd.gif}

None.gif
</script>
None.gif
</head>
None.gif
<body id='console'></div>
None.gif
</body>
None.gif
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值