2012-03-16 3 views
0

로 리디렉션하는 것은 모두 htmls해서 getJSON 응답은 내가 아래에 또 다른 HTML 페이지에 내해서 getJSON 응답을 리디렉션 할 또 다른 HTML 페이지

index.html을

$(document).ready(function() { 
alert("load"); 
    $.getJSON("http://10.0.2.2:8080v1/service/26/1", 
    function(data) { //want to redirect this response display.html 
    $.each(data, function(id, obj){ 
      $.each(obj, function(propName, value){ 
       // console.log(propName + ": " + value); 
       alert("propName: "+propName+" value: "+value); 
      }); 
     }); 


    }); 

    document.addEventListener("deviceready", onDeviceReady, true); 

}); 

function onDeviceReady(){ 
    navigator.notification.alert("PhoneGap is working"); 

} 

</script> 

</head> 
<body> 

</body> 
</html> 

display.html

에서 코드입니다 이 코드는 응답 데이터를 테이블 형식으로 표시합니다. 당신은 display.html 당신은 당신이 완료 당신해서 getJSON 일단 display.htm하는 페이지를 리디렉션 할 것을 의미 함이

 <body> 
    <table width="100%" cellspacing="3"> 
     <tr align="center"> 
     <td bgcolor="#474646" style="color: #fff; >first column</td> 
     <td bgcolor="#474646" style="color: #fff; >second column</td> 
     <td bgcolor="#474646" style="color: #fff; >third column</td> 

     </tr> 
     <tr align="center"> 
     <td>firstcolumn</td> 
     <td>secondcolumn</td> 
     <td>thirdcolumn</td> 
     </tr> 
     </table> 

    </body> 
+0

왜 display.html에서'getJson'을하지 않습니까? –

+0

당신은 내게 말할 수 있습니다. 만약 display.html에 getjson을 쓰면 응답을 테이블에 표시 할 수 있습니까 – user1265530

답변

0

에 사용하도록해서 getJSON 응답을 전송하는 방법에 지금 나를 도울 수 있습니까? 그렇다면 다음을 시도하십시오.

$.getJSON("http://10.0.2.2:8080v1/service/26/1", 
    function(data) { 
    window.location = "display.html"; 
}); 

또한 URL 서식이 잘못 지정되어있는 것으로 보입니다. 나는 당신이없는 생각에 "/"가이 "http://10.0.2.2:8080/v1/service/26/1"과 같아야 있도록 "V1"이전

편집 :

귀하의 의견을, 그것은 단지 index.html의 본문에 display.html의 내용을로드하려는 것 같습니다. 그렇다면 getJSON을 사용하고 싶지 않습니다. 아래에서 '로드'를 원한다고 생각합니다.

<script type="text/javascript"> 
    $(document).ready(function() { 
     alert("load"); 
     $('#someDiv').load('display.html'); 
     document.addEventListener("deviceready", onDeviceReady, true); 
    }); 
</script> 
<body> 
    <div id='someDiv'></div> 
</body> 

display.htm의 경로가 올바른지 확인하십시오.

+0

03-16 18 : 05 : 53.908 : E/chromium (576) : external/chromium/net/disk_cache/backend_impl .cc : 1107 : [0316/180553 : ERROR : backend_impl.cc (1107)] 심각한 오류 발견 -8 – user1265530

+0

index.html에서 응답을 받고 display.html 표에 인쇄하는 방법에 대해 저에게 한 말씀 해주실 수 있습니다 – user1265530

+0

그래도이 문제가 발생하면 알려주세요. 할 수있는 한 자세히 설명해주십시오. – davehale23