日期:2014-05-16 浏览次数:20610 次
<!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" >
<head>
<title>Ajax</title>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "http://seman.com/ajax.js?version=" + Math.random(), true);
xmlhttp.setRequestHeader("Content-type", "text/javascript");
xmlhttp.send();
}
</script>
</head>
<body>
<div style="width:100px;height:100px;background-color:Yellow;">
</div>
</body>
</html>
<!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" >
<head>
<title>Ajax</title>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
$(window).load(function () {
$.ajax({
url: "http:seman.com/ajax.js?version=" + Math.random(),
dataType:"script"
});
})
</script>
</head>
<body>
<div style="width:100px;height:100px;background-color:Yellow;">
</div>
</body>
</html>
document.getElementsByTagName("div")[0].style.backgroundColor = "red";