找到nginx服务器中index页面并进行修改 vim /usr/local/webserver/nginx/html/index.html
第二步:修改nginx服务器中的index.html
将下列代码替换到index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
<script src="js/jquery-1.12.4.js"></script>
<script>
$(function(){
$("#doAjax").click(function(){
$.ajax({
type:"post",
url:"http://192.168.10.10/b", //此处为上面conf文件中配置的nginx访问地址
success:function(){
alert("请求成功");
},
error:function(){
alert("请求失败");
}
});
});
});
</script>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<button id="doAjax">13号技术</button>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>