2014-02-17 2 views
1

다양한 게시물을 읽었지만 해결책을 찾을 수 없습니다. 내가 URL을 http://somesite.com/test.html와 test.html를에 코드를 호출 오전 것은도메인 간 요청에 권한 부여 헤더가 설정되지 않았습니다.

$.ajax({ 
    type: "GET", 
    url: "http://anothersite.com/app_dev.php/rest/123", 
    crossDomain: true, 
    async: false, 
    beforeSend: function (xhr){ 
    alert('Befor Sent'); 
    var text = btoa("11" + ":" + "22"); 
    alert("Enc:" + text); 
    xhr.setRequestHeader("Authorization", "Basic " + text); 

}, 
error: function(jqXHR, textStatus, errorThrown){ 
    alert("errorThrown:" + errorThrown); 
}, 
success: function(){ 
    alert('Thanks for your comment!'); 
} 

});

나는 다시 401 오류가 나는 헤더를 검사 할 때 코드가 브라우저에서 실행되는 경우 문제가 발생에는 인증 헤더

답변

1

없다. 나는 phonegap에 이것을 시도하고 완벽하게 작동합니다.