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

迷津渡口

越感到迷惑 越接近真理

Ajax兼容创建XMLHTTP请求对象函数

Ajax需要根据不同的浏览器使用不同的方法创建请求对象。

一个常用的自建函数是兼容不同浏览器创建对象的,分享给大家~

function createRequest() {
	try {
		request=new XMLHttpRequest();
	} catch(tryMS) {
		try {
			request=new ActiveXObject("Msxml2.XMLHTTP");
		} catch(otherMS) {
			try {
				request=new ActiveXObject("Microsoft.XMLHTTP");
			} catch(failed) {
				request=null;
			}
		}
	}
	return request;
}

使用方法:

request=createRequest();
if (request == null) {
    alert("Can't create XMLHTTP Object!!!");
} else {
    // success and go on
}

直接调用函数即可创建请求对象了,但是最好在继续之前进行判断。

如果浏览器禁用了,往下的代码也没有意义了~

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

清空信息
关闭评论
coach hand purse
 coach hand purse 约 23 小时前回复
#192
<a href="http://www.gaiaescort.com/nike-zoom-pegasus-33-grey-white-shoesk">nike zoom pegasus 33 grey white</a> <a href="http://www.hatbest.com/kvinners-nike-lebron-15-gul-obuvi">kvinners nike lebron 15 gul</a> <a href="http://www.playcheater.com/asics-gel-kayano-21-menn-svart-gr%C3%B8nn-oransje-obuvk">asics gel kayano 21 menn svart gr酶nn oransje</a> <a href="http://www.alanyalinks.com/nike-air-max-1-print-gr%C3%A5-svart-obuvi">nike air max 1 print gr氓 svart</a> <a href="http://www.mxclimited.com/air-jordan-retro-10-negro-nyc-zapatosl">air jordan retro 10 negro nyc</a> <a href="http://www.ueaydin.com/nike-cortez-nylon-femminile-light-rosa-scarpeh">nike cortez nylon femminile light rosa</a>
coach hand purse http://www.conniesegal.com/coach-hand-purse-coachh
dealingsnet
 dealingsnet 2019-04-24 21:00回复
#191
<a href="http://www.emunashipping.com/jordan-14-noir-toe-bon-march%C3%A9-chaussurese">jordan 14 noir toe bon march茅</a> <a href="http://www.freefna.com/nike-kyrie-1-multicolor-rosso-butya">nike kyrie 1 multicolor rosso</a> <a href="http://www.affiliaternd.com/nike-kd-7-or-bleu-schuhea">nike kd 7 or bleu</a> <a href="http://www.bebekhikayesi.com/air-jordan-retro-17-rose-gris-schuheb">air jordan retro 17 rose gris</a> <a href="http://www.bladespares.com/kd-7-nike-basketbtout-chaussures-butyc">kd 7 nike basketbtout chaussures</a> <a href="http://www.cikotein.com/air-jordan-18-negro-and-azul-for-venta-nc-obuve">air jordan 18 negro and azul for venta nc</a>
dealingsnet http://www.dealingsnet.com/
famelabcyprus
 famelabcyprus 2019-04-24 17:35回复
#190
<a href="http://www.atlantaaiport.com/bon-march%C3%A9-new-balance-574-hommes-vert-trainerse">bon march茅 new balance 574 hommes vert</a> <a href="http://www.donareseguros.com/adidas-predator-gold-skor">adidas predator gold</a> <a href="http://www.royalokavango.com/paul-george-hardwood-classic-jersey-nflr">paul george hardwood classic jersey</a> <a href="http://www.shufiparis.com/oakland-raiders-15-michael-crabtree-olive-2017-salute-to-service-limited-jersey-nflv">oakland raiders 15 michael crabtree olive 2017 salute to service limited jersey</a> <a href="http://www.thegroceri.com/red-white-and-blue-ralph-lauren-polo-shirt-polor">red white and blue ralph lauren polo shirt</a> <a href="http://www.roctaam.com/air-jordan-future-enfant-philippines-trainersce">air jordan future enfant philippines</a>
[url=http://www.famelabcyprus.com/]famelabcyprus[/url]
vuurogen
 vuurogen 2019-04-24 08:16回复
#189
<a href="http://www.unefinemouche.com/nike-air-max-lunar-1-mujeres-gris-blanco-zapatosk">nike air max lunar 1 mujeres gris blanco</a> <a href="http://www.ayuinc.com/hombres-nike-shox-turbo-21-amarillo-azul-zapatosp">hombres nike shox turbo 21 amarillo azul</a> <a href="http://www.unirlisboa.com/the-north-face-inlux-insulated-jacket-review-northfaceh">the north face inlux insulated jacket review</a> <a href="http://www.escortfeeds.com/dam%C3%A4nner-asics-gel-kinsei-4-himmelblau-blau-schuhej">dam盲nner asics gel kinsei 4 himmelblau blau</a> <a href="http://www.rdjanitorial.com/air-jordan-retro-4-kvinders-mintgr%C3%B8n-appelsin-skoh">air jordan retro 4 kvinders mintgr酶n appelsin</a> <a href="http://www.bookoobeats.com/adidas-springblade-pro-jaune-vert-chaussuresh">adidas springblade pro jaune vert</a>
vuurogen http://www.vuurogen.com/
rosebasil
 rosebasil 2019-04-24 04:34回复
#188
<a href="http://www.reviewtogel.com/nike-flyknit-trainer-white-kanye-shoesk">nike flyknit trainer white kanye</a> <a href="http://www.igrejamormon.com/nike-air-max-90-current-vt-lsr-sort-gul-skoj">nike air max 90 current vt lsr sort gul</a> <a href="http://www.skonya.com/adidas-ultra-boost-triple-rot-schuheh">adidas ultra boost triple rot</a> <a href="http://www.monsterplate.com/grey-adidas-tubular-shadow-shoesk">grey adidas tubular shadow</a> <a href="http://www.kentimpendik.com/michael-kors-jet-set-crossbody-pastel-pink-mkh">michael kors jet set crossbody pastel pink</a> <a href="http://www.attivopizza.com/kvinner-nike-lebron-13-bl%C3%A5-svart-obuvi">kvinner nike lebron 13 bl氓 svart</a>
rosebasil http://www.rosebasil.com/
adidas yeezy ek艧i
 adidas yeezy ek艧i 2019-04-23 17:34回复
#187
<a href="http://www.shubhlakshyaspecialedu.com/current/kinetix-lonair-lacivert-erkek-%c3%a7ocuk-tekstil-ayakkab%c4%b1-100322175-flo">kinetix lonair lacivert erkek 莽ocuk tekstil ayakkab谋 100322175 flo</a><a href="http://www.shubhlakshyaspecialedu.com/deeply/new-balance-574-custom-foot-locker-sneaker-news-2-new-balance-574-custom-by-sneaker-news">new balance 574 custom foot locker sneaker news 2 new balance 574 custom by sneaker news</a><a href="http://www.shubhlakshyaspecialedu.com/difficult/zapatillas-babolat-tenis-propulse-4-ni%c3%b1o-palermo-tenis">zapatillas babolat tenis propulse 4 ni帽o palermo tenis</a><a href="http://www.shubhlakshyaspecialedu.com/draw/lacoste-kad%c4%b1n-beyaz-%c3%a7anta">lacoste kad谋n beyaz 莽anta</a>
adidas yeezy ek艧i http://www.bhavsagar.com/colorful/adidas-yeezy-ek%c5%9fi
enventsurvey
 enventsurvey 2019-04-23 13:19回复
#186
<a href="http://www.romoautocare.com/air-jordan-retro-31-viola-grigio-scarpel">air jordan retro 31 viola grigio</a> <a href="http://www.industrialegy.com/nike-kd-trey-5-pink-gold-shoesj">nike kd trey 5 pink gold</a> <a href="http://www.bewustvitaal.com/nike-air-max-tailwind-5-kvinders-r%C3%B8d-gul-skoi">nike air max tailwind 5 kvinders r酶d gul</a> <a href="http://www.flushandhunt.com/nike-air-max-90-em-viola-rosso-scarpeq">nike air max 90 em viola rosso</a> <a href="http://www.kendalfewster.com/air-jordan-ultra-fly-purple-white-shoesj">air jordan ultra fly purple white</a> <a href="http://www.gisusalon.com/michael-kors-jet-set-wallet-mens-mkh">michael kors jet set wallet mens</a>
enventsurvey http://www.enventsurvey.com/
softballinsider
 softballinsider 2019-04-22 19:20回复
#185
<a href="http://www.onewebsql.net/lebron-12-low-orange-and-bl%C3%A5-obuvc">lebron 12 low orange and bl氓</a> <a href="http://www.onlinne.net/nike-free-run-3-5.0-hot-punch-neon-rose-zalando-chaussuresg">nike free run 3 5.0 hot punch neon rose zalando</a> <a href="http://www.onpointsports.net/nike-zoom-vomero-9-in-esecuzione-scarpe-sp15-chaussuresa">nike zoom vomero 9 in esecuzione scarpe sp15</a> <a href="http://www.oqibo.net/air-max-90-for-verkauf-ph-butya">air max 90 for verkauf ph</a> <a href="http://www.ourjourneychurch.net/nike-free-flyknit-5.0-damenn-rosa-butyd">nike free flyknit 5.0 damenn rosa</a> <a href="http://www.ouverturefacile.net/air-jordan-ni%C3%B1os-zapatos-verde-marr%C3%B3n-scarpeg">air jordan ni帽os zapatos verde marr贸n</a>
softballinsider http://www.softballinsider.net/
elgintransfer
 elgintransfer 2019-04-21 12:52回复
#184
<a href="http://www.kywordsmith.com/nike-air-max-r%C3%B8d-hvid-sort-skoi">nike air max r酶d hvid sort</a> <a href="http://www.zanelebeauty.com/nike-air-max-thea-pastel-rose-chaussuresh">nike air max thea pastel rose</a> <a href="http://www.ukclubdj.com/chicago-white-sox-new-era-2017-mlb-players-weekend-kids-59fifty-cap-hatl">chicago white sox new era 2017 mlb players weekend kids 59fifty cap</a> <a href="http://www.statusmarathi.com/nike-air-max-tavas-noir-and-orange-chaussuresh">nike air max tavas noir and orange</a> <a href="http://www.theartofaj.com/mujeres-nike-internationalist-oro-verde-zapatosk">mujeres nike internationalist oro verde</a> <a href="http://www.paralirulet.com/nike-air-max-tailwind-7-blac-green-shoesj">nike air max tailwind 7 blac green</a>
elgintransfer http://www.elgintransfer.com/
visasdecanada
 visasdecanada 2019-04-20 20:57回复
#183
<a href="http://www.kelseybsbooks.com/adidas-casual-schuhe-schwarz-rot-butya">adidas casual schuhe schwarz rot</a> <a href="http://www.michellestill.com/adidas-projoator-instinct-rojo-chaussuresf">adidas projoator instinct rojo</a> <a href="http://www.relojesorion.com/nike-flynit-air-max-grigio-butya">nike flynit air max grigio</a> <a href="http://www.sarabeenie.com/nike-free-flyknit-4.0-sort-hvid-schuheg">nike free flyknit 4.0 sort hvid</a> <a href="http://www.selfdriverbus.com/ralph-lauren-vest-orange-brown-poloz">ralph lauren vest orange brown</a> <a href="http://www.waterlowcards.com/kvinners-supra-tk-society-svart-bl%C3%A5-chaussuresa">kvinners supra tk society svart bl氓</a>
visasdecanada http://www.visasdecanada.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸