Rest API를 처음 사용합니다. 내 응용 프로그램에서 크로스 도메인 나머지 API를 호출하려고합니다.나머지 API - 405 메소드가 허용되지 않습니다.
$.ajax({
type: "GET",
async: false,
url: 'http://xx.xxx.xxx.xx:9003/GetProjectList',
contentType: "application/json",
dataType: "json",
traditional: true,
CrossDomain: true,
data: {
StartDate: '2016-12-20',
EndDate: '2017-01-10'
},
success: function (data) {
alert("Success");
alert(data);
},
error: function (xhr, textStatus, errorThrown) {
alert("Failed");
alert(xhr);
alert(textStatus);
alert(errorThrown);
}
});
하지만 난 여기 아무것도 실종
OPTIONS http://xx.xxx.xxx.xx:9003/GetProjectList?StartDate=2016-12-20&EndDate=2017-01-10 405 (Method Not Allowed)
XMLHttpRequest cannot load http://xx.xxx.xxx.xx:9003/GetProjectList?StartDate=2016-12-20&EndDate=2017-01-10. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:64207' is therefore not allowed access. The response had HTTP status code 405.
으로 오류를 얻고있다 - 여기 내 코드? 모든 코드 또는 구성?
브라우저 나 우편 배달부에서 해당 URL을 직접 누르는 것이 좋습니다. 하지만 응용 프로그램에서 작동하지 않습니다.
이 기본 CORS 오류입니다. 응답 헤더에 필수 CORS 헤더를 설정해야합니다. 거기에 사용할 수있는 톤의 대답이 있습니다. 그런데 서비스 웹 API 또는 wcf-rest가 있습니까? 두 태그를 함께 추가하면 안됩니다. – Developer
CORS 만 허용하면됩니다. 그것을 알면, 그것은 항상 작동하지 않습니다! –
GET 요청에서 Content-Type을 설정하는 이유는 무엇입니까? – Quentin