안녕하세요..

 

폰갭에서 ajax 구현하는데 잘 안되네요;

 

혹시 제가 눈여겨 봐야 할부분이 있는지요?.(테스트환경,타켓서버환경등등..)

 

테스트 환경은 안드로이드시물레이션이고요,phonegap,jquerymobile이용해서 개발하고 있습니다.

 

몰론 주소는 특정서버에있는 파일명으로 변경했고요..

 

function appReady(){
var ajax = new XMLHttpRequest();
 ajax.open("GET","https://xxxx.xxxxx.com/xxxx/xxxx.ashx?method=GetUser&email=xxx@xxxx.com&pwd=123456",false);
    ajax.send();
    ajax.onreadystatechange=function(){
        if(ajax.readyState == 4) {//Request complete !!
            if (ajax.status == 200 || ajax.status == 0) { // OK response
                alert(ajax.responseText);
                document.getElementById('main').innerHTML = ajax.responseText;
            }
        }
    }
}

 

위에껏이 안되셔 보니 아래 댓글에

 

 check for cross-domainscripting issues...............(그 다음은 짧은 영어실력이라서 생략)

 var rootpath; 
rootpath = "https://the.same.dam.place/foo.asp";   // did not work! 
rootpath = "foo.asp";   // shortening it worked. 
function read_foo(whatever) 
{ 
    var url = rootpath + "?whatever=" + whatever; 
    xmlHttp = GetXmlHttpObject(stateChanged); 
    xmlHttp.open("GET", url , true); 
    xmlHttp.send(null); 
} 
function stateChanged() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") 
    { 
        var return_place = document.getElementById('return_place'); 
        var thetext = xmlHttp.responseText; 
        return_place.innerHTML= thetext; 
    } 
} 

 

깜박눈이라서 제가 볼때는 별 차이가 없는거 같은데...


cross-domain 이라서 따로 처리해줘야 하는 부분이 있나요??

 

 

http://stackoverflow.com/questions/8270385/phonegap-xmlhttprequest-responsetext-empty-with-android-but-contain-data-in-ipho