`
jianghg2010
  • 浏览: 63799 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ajax与js

阅读更多
<html>
<head>
<script type="text/javascript">
var xmlhttp = false;
function CreateXMLHttp(){
try{
xmlhttp = new XMLHttpRequest();
}
catch (e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed){
xmlhttp = false;
}
}
}
return xmlhttp;
}
xmlhttp = CreateXMLHttp();
xmlhttp.open("post","a.html",true);
xmlhttp.onReadyStateChange = getResult;
xmlhttp.send();
function getResult(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
alert(xmlhttp.responseText);
}
}
</script>
</head>
</html>


<html>
<head>
<script type="text/javascript">
var xmlhttp;
function showHint(){
alert(xmlhttp+"1");
alert((undefined == xmlhttp)+"2");
alert((null == xmlhttp)+"3");
alert(("" == xmlhttp)+"4");
return xmlhttp;
}
</script>
</head>
<body>
<form>
First Name:<input type="text" id="txt1" onkeyup="showHint()" />
</form>
<p>Suggestions: <span id="txtHint"></span></p>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics