html页面代码
-----------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US">
<!--
* Created on 2015-5-21
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
-->
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf8"/>
<title>hello </title>
<script type="text/javascript">
var xmlhttp_request=false;
try{
if(window.ActiveXObject){
for(var i=5;i;i--){
try{
if(i==2){
xmlhttp_request=new ActiveXObject("Microsoft.XMLHTTP");
}else{
xmlhttp_request=new ActiveXObject("Msxml2.XMLHTTP."+i+".0");
xmlhttp_request.setRequestHeader("Content-Type","text/xml");
xmlhttp_request.setRequestHeader("Charset","utf-8");
}
break;
}catch(e){
xmlhttp_resquest=false;
}
}
}else if(window.XMLHttpRequest){
xmlhttp_request=new XMLHttpRequest();
if(xmlhttp_request.overrideMimeType){
xmlhttp_request.overrideMimeType("text/xml");
}
}
}catch(e){
xmlhttp_request=false;
}
function hello(btn){
var url="14.8.php";
xmlhttp_request.onreadystatechange=function(){
if(xmlhttp_request.readyState==4 && xmlhttp_request.status==200){
btn.value=xmlhttp_request.responseText;
alert(xmlhttp_request.responseText);
}
}
xmlhttp_request.open("POST",url,true);
xmlhttp_request.send(null);
}
</script>
</head>
<body>
<input type="button" value="第一个AJAX程序" name="submit" id="submit" onclick="hello(this);"/>
</body>
</html>
#####################################################################################
php代码
<?php
/*
* Created on 2015-5-21
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
echo "Hello,Ajax!";
?>