0
jquery에서 내 webservice (웹 API)의 데이터가 필요한 안드로이드 용 phonegab 앱으로 아약스 호출을하려고합니다.웹 API 2에서 아약스 호출 실패
Nuget에서 Cors를 설치하고이 서비스를 활성화했습니다.
안전하지 않은 헤더 "기원"JQuery와 - 1.10.2.js 설정 거부 : 8699 없음 '액세스 제어 - 허용 - 원산지를'나는 크롬에서 내 서비스를 테스트 할 때
는하지만이 오류가 계속 헤더가 요청 된 리소스에 있습니다. 따라서 원본 'null'은 액세스가 허용되지 않습니다.
내 Ajax 코드는 다음과 같습니다이 내 webconfig에 추가됩니다
function list() {
var result = null;
$.ajax(
{
url: 'mysite',
beforeSend: function (xhr) {
xhr.setRequestHeader("Origin", "*");
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
},
contentType: 'application/json; charset=utf-8',
type: 'GET',
crossDomain: true,
async: false,
success: function (data) {
result = data;
}
});
return result;
};
업데이트
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>