2012-10-30 6 views
0

자바 스크립트에서 여러 함수를 호출하여 사용자 이름/이메일 주소/비밀번호를 가져옵니다. 모든 것이 잘되면 goForLogin()으로 가서 chrildbrowser를 엽니 다. 내가 오류 ko를 얻을 (아래 참조) :Childbrowser가 종료됩니다.

먼저 내 코드 :

 function goForLogin(emailaddress, value){ 
      var xmlhttp; 
      xmlhttp=new XMLHttpRequest(); 
      xmlhttp.open("POST","http://dev.server.com/test/login",true); 
      xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
      xmlhttp.send("email=" + emailaddress + "&password=" + value); 

      xmlhttp.onreadystatechange=function() 
      { 
       if (xmlhttp.status==200) 
       { 

        value = null; 
        window.plugins.childBrowser.showWebPage('http://dev.server.com'); 
       } else { 
        alert("FAILED"); 
       } 
      } 
     } 
응용 프로그램을 종료

* 인해 캐치되지 않는 예외 'NSInvalidArgumentException', 이유에 '응용 프로그램 모달 활성 컨트롤러를 제공하기 위해 노력 . ' * 먼저 던져 호출 스택 : (0x154012 0x25fce7e 0x478721 0x479777 0x4797b7 0x6a68 0x67471 0x66c5e 0x67039 0x26106b0 0x1198035 0xd7f3f 0xd796f 0xfa734 0xf9f44 0xf9e1b 0x33be7e3 0x33be668 0x38f65c 0x2366 0x2295)의 libC++ abi.dylib : 예외를 throw라고 종료 (lldb)

최신 코도 바 및 Childbrowser, Xcode 4.4 버전.

답변

2

알았습니다. xmlhttp.onreadystatechange 문 때문에 childBrowser는이 스크립트에서 세 번 열리게됩니다. 그것은 사과에 의해 허용되지 않습니다 - 미안, 왜 잊어 버렸는지 - 그래서 전화를 했어.

내 자바 스크립트 : 그것은 다음과 같습니다

내 HTML에서 마지막으로
function some_function2(url, callback) { 
     var httpRequest; // create our XMLHttpRequest object 
     if (window.XMLHttpRequest) { 
      httpRequest = new XMLHttpRequest(); 
     } else if (window.ActiveXObject) { 
      // Internet Explorer is stupid 
      httpRequest = new 
      ActiveXObject("Microsoft.XMLHTTP"); 
     } 
     httpRequest.onreadystatechange = function() { 

      // inline function to check the status 
      // of our request 
      // this is called on every state change 
      if (httpRequest.readyState === 4 && 
      httpRequest.status === 200) { 
      callback.call(httpRequest.responseXML); 
      // call the callback function 
     } 
     }; 
     httpRequest.open('POST', url, true); 
     httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
     httpRequest.send("[email protected]&password=1"); 
     } 


function call() { 
    // call the function 
    some_function2("http://dev.server.com/account/login/", function() { 
       console.log(this); 
       callChildBrowser(); 
       }); 
       console.log("this will run before the above callback"); 

} 


function callChildBrowser(){ 
    window.plugins.childBrowser.showWebPage('http://dev.server.com'); 
    } 

:

<button id="butten" onclick="call()">WORKS</button> 
관련 문제