web前端ajax请求接口时,发生error。{“error”: {“message”: “Only Support POST Method”, “code”: 1001}}


(laughingxj) #1
$.ajax({
		type:'POST',
		headers:{
			'Authorization':'Basic YTZkYjU3ZGNmNmE5NmE4Y2NkNjQyMWY0OmJlM2JhYWZiODU0ODA0YjZiOTM3OTk4NA==',
		},
		crossDomain : true,
		async: true,
		url:'https://api.jpush.cn/v3/push',
		dataType: 'json',
		data:{
		    "platform": ["android"],
		    "audience": {
		        "alias":'alias_0'
		    },
		    "notification": {
		        "android": {
		            "alert": "Hi, JPush!",
		            "title": "Send to Android"
		        }
		    }
		},
		success:function(res){
			alert(JSON.stringify(res));
		}
	});

(laughingxj) #3

test-Jpush.html:1 XMLHttpRequest cannot load https://api.jpush.cn/v3/push. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://wxj.allweb.qipeiren.com:1111’ is therefore not

allowed access. The response had HTTP status code 405.


#4

之前看错了,你的报错信息说明了,1001,只支持post,

response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘htts://localhost:3000’ is therefore not allowed access.

根据这个报错应是跨域问题,请检查是否开通了443、80端口,是否屏蔽了极光的域名
自行搜索:No ‘Access-Control-Allow-Origin’ header