2011-10-16 2 views
1

두 정수 (두 정수 모두)를 취하는 ActionController가 있습니다.JavaScript를 사용하는 매개 변수로 액션 컨트롤러를 실행하는 가장 좋은 방법은 무엇입니까?

사용자가 오른쪽 또는 왼쪽으로 밀면 내 페이지가 사용자를 다른 페이지로 안내합니다. 사용자가 페이지의 끝에 도달하면 액션 컨트롤러가로드 할 수있는 새로운 카테고리로 리디렉션하고 싶습니다.

$(document).keydown(function (e) { 
     var code = (e.keyCode ? e.keyCode : e.which); 

     var currentPage = $("#CurrentPage").val(); 
     var numberOfPges = $("#NumberOfPages").val(); 

     if (code == 39) { 

      if (currentPage < numberOfPges) { 
       // Næste side 
       changePage(parseInt(currentPage) + 1); 
       $(document).focus(); 
      } 
      else {    
      // Send user to the next category 
      // $("#nextCategory") 
      } 

     } 
     else if (code == 37) { 
      // Tilbage 
      if ((parseInt(currentPage) - 1) != 0) { 
       changePage(parseInt(currentPage) - 1); 
       $(document).focus(); 
      } 
      else { 
      // Send user to the previous category 
      // $("#previousCategory") 
      } 

     } 
    }); 

기본적으로 나는 중 하나

$("#nextCategory") 
or 
$("#nextCategory") 

의 가치와 페이지로 ActionController를 호출하고 싶은 = 1

자바 스크립트를 표시하는보기와 같은 ActionController에 있습니다.

/Survey2/DisplayQuestions? 카테고리 ID = 2 & 페이지 = I가 전체 페이지를 업데이트 할 1

. 가장 좋은 방법은 무엇입니까?

감사합니다.

답변

0

jQuery post 또는 jQuery submit을 사용할 수 있습니다. 이

//Send user to the next category 
$.post("/somepath/someaction", "#nextCategory"); 
비슷한있을 것이다 당신의 다른 문에

관련 문제