Ajax跨域解决
html部分
<script type="text/javascript">
var refundReturn = function(){
var paymentBody = {};
paymentBody.order_sn = "0sn00000";
paymentBody.success_url = "www.baidu.com";
$.ajax({
method: "POST",
url: 'http://localhost:8085/iprp_app/api/payment',
data: JSON.stringify(paymentBody),
dataType : "json",
success: function (data) {
if (data == "success") {
} else if (data == "fail") {
} else if (data == "cancel") {
}
},
error: function (xhr, textStatus, errorThrow) {
alert(xhr.readyState);
}
});
};
</script>
<body>
<button onclick="refundReturn()">微信支付</button>
</body>
java部分
web.xml文件内
<!--CORS跨域问题-->
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, POST, HEAD, PUT, DELETE, OPTIONS</param-value>
</init-param>
<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>Accept,Authorization,token,Origin, X-Requested-With, Content-Type, Last-Modified</param-value>
</init-param>
<init-param>
<param-name>cors.exposedHeaders</param-name>
<param-value>Set-Cookie</param-value>
</init-param>
<init-param>
<param-name>cors.supportsCredentials</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--CORS跨域问题-->
相关推荐
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo