ajax跨域

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="${pageContext.request.contextPath }/jquery.js"></script>
</head>
<body>
<button onclick="ok()">ok</button>
</body>
<script type="text/javascript">

    function ok(){
        $(function(){
            $.post(
//                 'http://localhost:8080/zday02/f',
                '${pageContext.request.contextPath}/f',
                function(data){
                    alert("ok")
                }
            )
        })
    }
</script>
</html>
原文地址:https://www.cnblogs.com/javaweb2/p/6626234.html