这应该可以帮助您更好地理解它;)您的ajaxprocess.html如下所示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta name="author" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<title></title>
<style type="text/css">
*{margin:0px;padding:0px}
.content{
display:block;
width:300px;
height:300px;
border:1px solid #000000;
margin: 0 auto;
margin-top:30px;
}
.button{
margin:0 auto;
width:100px;
hight:100px;
display:block;
}
.strong{
display:none;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var myName = 'John';
var myImage = $('<img src = "path to your image"/>');
$('.button').click(function(){
$.ajax({
url:'load.html',
success:function(data){
$('.content').html(data);
//$(".images").append(myImage);//Uncomment this if you want to insert Your image...
$('.strong').fadeIn(2000,function(){
alert(data);//We shall alert our data after the DATA
alert(myName);//is Faded IN...
});
},error:function (xhr){
var msg ="Sorry there was an error:";
alert(msg+" "+xhr.statusText+" "+xhr.status);
}
});
});
});
您的load.html看起来像这样:现在您只需将这两个文件复制到您的服务器上并仔细检查ajaxprocess.html 的外观......希望这会有所帮助:)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta name="author" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<title></title>
<style type="text/css">
*{margin:0px;padding:0px}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<strong class="strong">This was loaded OK!!!<span class="images"></span></strong>
</body>
</html>