도메인 간 AJAX POST 요청이 휴대 전화의 브라우저를 포함하여 웹 브라우저에서 완벽하게 잘 작동 안드로이드에서 작동하지 않는,하지만 기본 응용 프로그램이 작동하지 않습니다 사용자가 로그인 자격 증명을 입력해야하는 로그인 양식은 heroku에서 호스팅되는 서버에 의해 확인되고 유효한 자격 증명이 입력되면 json {"success":true}
을 반환합니다.폰갭 도메인 간 AJAX POST 요청은
내 아약스 스크립트 :
$.ajax({
type: "POST",
url: "http://domain.com/public/auth/app-login",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "json",
data: {identity: <username from form>, password: <password from form>},
crossDomain: true,
cache: false,
success: function(data) {
obj = JSON.parse(data);
if (obj && obj.success === true) {
window.location.href = 'home.html';
}
},
error: function(e) {
alert('Error: ' + e.message);
}
});
단계는이 문제를 해결하기 위해 촬영 :
- Domain whitelisting - config.xml에
<access origin="http://domain.com/public/auth/app-login" />
$.support.cors = true;
또는 jQuery.support.cors = true;
- 안 캐싱에게 크로스 도메인을 할 수 있도록 jQuery를 말하는
<access origin="*" />
cache: false
도움을 주시면 감사하겠습니다.
안녕하십니까.이 문제를 해결해 주시겠습니까? 당신은 솔루션을 공유 할 수 있습니까? –
예. 해결했습니다. 다음을 시도하십시오. 1. 도메인 허용 목록 작성 (http://docs.phonegap.com/en/2.1.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide) 2. XmlHttpReqquest를 사용하여 서버와 통신하십시오. http를 참조하십시오. : //stackoverflow.com/questions/9464563/how-do-i-call-remote-api-using-phonegap-for-android – h4kl0rd