好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

Ajax对象的readyState属性和onreadystatechange事件

使用Ajax对象时,浏览器使用请求对象的readyState属性来告诉回调函数请求处于其生命周期的哪一个阶段。

过程为:

request=createRequest();

0:对象建立但连接尚未初始化

request.open("GET",url,true);

1:连接初始化,请求已准备好可以发送

request.send(null);

2:请求已发送到服务器,服务器正在处理请求

3:服务器响应,正在下载数据到请求对象

4:服务器响应完成,数据准备就绪


onreadystatechange事件在每次状态改变时都会调用回调函数。

request.onreadystatechange=test;

回调函数test在每次状态改变时都会被调用执行,因此如果需要响应完成才真正执行某些代码可以这样做:

function test() {
    // 判断状态码是否为4
    if (request.readyState == 4) {
        // 判断连接是否成功
        if (request.status == 200) {
            // 成功后执行的代码
        }
    }
}

注意事件后面的回调函数是没有()的,否则变成调用了~

点赞1
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
avonew
 avonew 2018-12-10 01:35回复
#24
<a href="http://www.rivacover.com/air-jordan-true-flight-pink-quilt-sportsc">air jordan true flight pink quilt</a> <a href="http://www.slimtobody.com/bon-march%C3%A9-asics-gel-sendai-2-femmes-bleu-trainersd">bon march茅 asics gel sendai 2 femmes bleu</a> <a href="http://www.mgnmilitaria.com/texas-rangers-gray-hat-linux-hata">texas rangers gray hat linux</a> <a href="http://www.rahwindsor.com/nike-air-max-zero-white-on-feet-runninga">nike air max zero white on feet</a> <a href="http://www.ceethebarber.com/michael-kors-brown-and-pink-purse-mkr">michael kors brown and pink purse</a> <a href="http://www.saatchixblog.com/hombres-nike-air-max-95-rojo-shoesn">hombres nike air max 95 rojo</a>
rightreaxion
 rightreaxion 2018-12-06 12:18回复
#23
<a href="http://www.ericbarrak.com/bon-march%C3%A9-nike-kobe-7-femmes-bleu-footg">bon march茅 nike kobe 7 femmes bleu</a> <a href="http://www.brianrubeo.com/jordan-elephant-print-hats-patterns-hatb">jordan elephant print hats patterns</a> <a href="http://www.colorngrey.com/a-buon-mercato-nike-flyknit-racer-femminile-rosso-sneakerg">a buon mercato nike flyknit racer femminile rosso</a> <a href="http://www.purchasemenus.com/nike-foamposite-pink-nba-runningd">nike foamposite pink nba</a> <a href="http://www.justdoitperu.com/a-buon-mercato-nike-air-speed-turf-femminile-nero-sneakerd">a buon mercato nike air speed turf femminile nero</a> <a href="http://www.veruccapedis.com/nobis-jacket-canada-nobisr">nobis jacket canada</a>
rightreaxion http://www.rightreaxion.com/
davidmyre
 davidmyre 2018-12-01 19:41回复
#22
<a href="http://www.aberturasdh.com/air-jordan-phase-purple-silver-shoesc">air jordan phase purple silver</a> <a href="http://www.jknets.com/nike-air-zoom-vomero-10-mens-skos">nike air zoom vomero 10 mens</a> <a href="http://www.saeedlawyer.com/purple-ferragamo-belt-beltr">purple ferragamo belt</a> <a href="http://www.hyaluronicset.com/parajumper-m%C3%B6ssa-parajumpersr">parajumper m枚ssa</a> <a href="http://www.yupoji.com/air-jordan-12-pink-dynamic-skod">air jordan 12 pink dynamic</a> <a href="http://www.thankhuc.com/pink-grey-mens-nike-sb-zoom-p-rod-x-shoes-sneakerg">pink grey mens nike sb zoom p rod x shoes</a>
davidmyre http://www.davidmyre.com/
offshoretent
 offshoretent 2018-11-28 17:57回复
#21
<a href="http://www.raiedumacon.com/nike-schuhe-2017-dam%C3%A4nner-rosa-shoesg">nike schuhe 2017 dam盲nner rosa</a> <a href="http://www.grassmannword.com/air-max-thea-floral-colourful-shoesd">air max thea floral colourful</a>
offshoretent http://www.offshoretent.com/
aloulavideos
 aloulavideos 2018-11-25 18:35回复
#20
<a href="http://www.instabuttons.com/ray-ban-aviator-black-frame-sunglassesr">ray ban aviator black frame</a> <a href="http://www.natalbags.com/barato-adidas-stan-smith-hombres-verde-trainersg">barato adidas stan smith hombres verde</a> <a href="http://www.oricastg.com/nike-air-max-90-kids-yellow-white-shoesg">nike air max 90 kids yellow white</a> <a href="http://www.raynne.com/bon-march%C3%A9-nike-air-max-direct-femmes-blanc-footb">bon march茅 nike air max direct femmes blanc</a> <a href="http://www.elitoyreviews.com/green-and-orange-polo-shirt-polor">green and orange polo shirt</a> <a href="http://www.gaeconomics.com/nike-dunk-quilted-patent-trainersf">nike dunk quilted patent</a>
aloulavideos http://www.aloulavideos.com/
theblases
 theblases 2018-11-24 10:00回复
#19
<a href="http://www.immoetvous.com/nike-air-max-1-hvid-night-factor-shoesv">nike air max 1 hvid night factor</a> <a href="http://www.lapcomit.com/los-angeles-rams-womens-jersey-nflr">los angeles rams womens jersey</a> <a href="http://www.mikeorlandoni.com/best-moncler-coat-monclerr">best moncler coat</a> <a href="http://www.dragongateusa.com/hombres-adidas-nmd-runner-gris-shoesn">hombres adidas nmd runner gris</a> <a href="http://www.pepinmystep.com/bon-march%C3%A9-nike-air-max-lunar-1-femmes-orange-skob">bon march茅 nike air max lunar 1 femmes orange</a> <a href="http://www.cantleylaw.com/air-jordan-11-retro-black-and-red-jordans-sneakerf">air jordan 11 retro black and red jordans</a>
theblases http://www.theblases.com/
ycbrowsbeauty
 ycbrowsbeauty 2018-11-18 22:36回复
#18
<a href="http://www.brodiebaranow.com/moncler-winter-jacket-women-monclerr">moncler winter jacket women</a> <a href="http://www.akncmusic.com/68-jaromir-jagr-jersey-nflv">68 jaromir jagr jersey</a> <a href="http://www.projetocidade.com/navy-blue-and-white-michael-kors-purse-mkr">navy blue and white michael kors purse</a> <a href="http://www.riddercorp.com/asics-gel-kayano-21-mujeres-plata-sportsc">asics gel kayano 21 mujeres plata</a> <a href="http://www.opelbeyinleri.com/coach-iphone-wristlet-coachr">coach iphone wristlet</a> <a href="http://www.shufiparis.com/adidas-zx-flux-schwarz-and-rose-gold-dam%C3%A4nner-glasses-shoesv">adidas zx flux schwarz and rose gold dam盲nner glasses</a>
ycbrowsbeauty http://www.ycbrowsbeauty.com/
walkerhut
 walkerhut 2018-11-17 03:23回复
#17
<a href="http://www.myenergytruth.com/new-york-yankees-hat-nz-007-hatf">new york yankees hat nz 007</a> <a href="http://www.aurelmar.com/%EF%BB%BFair-jordan-5-retro-herren-wei%C3%9F-fire-rot-schwarz-and-wei%C3%9F-shoesv">锘縜ir jordan 5 retro herren wei脽 fire rot schwarz and wei脽</a> <a href="http://www.rakebackhero.com/where-can-i-get-a-burberry-scarf-for-cheap-scarfr">where can i get a burberry scarf for cheap</a> <a href="http://www.mymascensores.com/air-jordan-17-shoesm">air jordan 17</a> <a href="http://www.aesqmed.com/nike-free-from-usa-trainersa">nike free from usa</a> <a href="http://www.jindianhua.com/parajumpers-ugo-super-lightweight-jacket-navy-parajumpersr">parajumpers ugo super lightweight jacket navy</a>
walkerhut http://www.walkerhut.com/
acrosstheory
 acrosstheory 2018-11-16 18:06回复
#16
<a href="http://www.mndrsngh.com/kobe-8-for-sale-manila-footg">kobe 8 for sale manila</a> <a href="http://www.inenigroup.com/jordan-true-flight-mid-top-pink-trainersa">jordan true flight mid top pink</a> <a href="http://www.specpilot.com/nike-huarache-white-nl-runningb">nike huarache white nl</a> <a href="http://www.davidmyre.com/billig-nike-dunk-dam%C3%A4nner-silber-shoese">billig nike dunk dam盲nner silber</a> <a href="http://www.gmanswindle.com/adidas-cc-ride-m-kids-shoes-pink-silver-sneakerc">adidas cc ride m kids shoes pink silver</a> <a href="http://www.aterisrail.com/adidas-eqt-adv-philippines-skos">adidas eqt adv philippines</a>
acrosstheory http://www.acrosstheory.com/
reganwhimpey
 reganwhimpey 2018-11-16 04:20回复
#15
<a href="http://www.sitopromo.com/air-jordan-son-of-mars-bordeaux-for-sale-houston-runninge">air jordan son of mars bordeaux for sale houston</a> <a href="http://www.michellestill.com/nike-air-huarache-dam%C3%A4nner-gold-runningd">nike air huarache dam盲nner gold</a> <a href="http://www.wearechicanos.com/canada-goose-womens-solaris-parka-canadagooser">canada goose womens solaris parka</a> <a href="http://www.nhadatmoivn.com/new-era-blue-snapback-hatg">new era blue snapback</a> <a href="http://www.walkerhut.com/nike-free-flyknit-3.0-womens-red-black-skod">nike free flyknit 3.0 womens red black</a> <a href="http://www.infotostudio.com/parajumpers-parka-canada-parajumpersr">parajumpers parka canada</a>
[url=http://www.reganwhimpey.com/]reganwhimpey[/url]
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸