2011-11-26 1 views
3

web.py 프레임 워크를 사용하여 내 웹 사이트를 설정하고 있습니다. 버튼을 클릭하면 서버에 데이터를 POST 한 다음생성 함수/산출량을 통해 데이터를 보내려고합니다. 기본적으로 준비된대로 데이터를 산출하고 데이터 기능이 완전히 끝날 때까지 기다리지 않습니다.Web.py | POST 및 AJAX (생성기 함수)를 통해 데이터 산출량

나는 yield to work via GET이되지만, AJAX를 통한 POST 구현이 문제가됩니다.

def POST(self): 
    web.header('Content-type','text/html') 
    web.header('Transfer-Encoding','chunked') 
    yield "hello" 
    sleep(10) 
    yield "hello" 

그리고 내 자바 스크립트 :

<script type="text/javascript"> 
    jQuery(document).ready(function() { 
     jQuery("#button").click(function() { 
      jQuery.ajax({ 
        type: "POST", 
        dataType: "text", 
        cache: false, 
        success: function(data){ 
        jQuery("#container").html(data) 
        } 
       }); }); }); 
</script> 

출력 :

HelloHello (after 10 seconds) 
rather than.. 
Hello (10 second delay) Hello 

: 나는 web.py의 내 로컬 컴퓨터에서 서버에 내장을 사용하고 있습니다.

답변

2

어리석은 me - AJAX는 스트리밍을 지원하지 않습니다. 따라서 Comet 또는 HTML5 WebSocket이 도움이 될 수 있습니다.