2011-09-06 2 views
0

아래의 코드를 얻기 위해 몇 가지 stackoverflow 질문을 결합했습니다. 링크는 ajax를 통해 모달 벌금으로 편집 양식을로드하지만 양식이 제출되면 전체 페이지가 제출되고 다시로드됩니다. 내가 다시 모달에만 모달 싶습니다. 후 숨겨진 iframe이에 jquery 대화 상자로드 양식을 통해 아약스, 양식 대화 상자를 다시 제출하십시오.

을 양식을 제출

  • 는 AJAX
  • 를 통해 양식을 제출, 제출 모델의 내용을 갱신 처리 :

    <script charset="utf-8" type="text/javascript"> 
    $(document).ready(function() { 
    
    jQuery(".ajax").click(showDialog); 
    
    //variable to reference window 
    $myWindow = jQuery('##myDiv'); 
    
    //instantiate the dialog 
    $myWindow.dialog({ height: 350, 
    width: 400, 
    modal: true, 
    position: 'center', 
    autoOpen:false, 
    title:'Edit Policy', 
    overlay: { opacity: 0.5, background: 'black'}, 
    open: function(type,data) { $(this).parent().appendTo("form"); } 
    }); 
    } 
    ); 
    
    //function to show dialog 
    var showDialog = function() { 
    $('##myDiv').load(
    this.href, 
    {}, 
    function (responseText, textStatus, XMLHttpRequest) { 
    //if the contents have been hidden with css, you need this 
    $myWindow.show(); 
    //open the dialog 
    $myWindow.dialog("open"); 
    } 
    ); 
    
    //prevent the browser to follow the link 
    return false; 
    } 
    
    //function to close dialog, probably called by a button in the dialog 
    var closeDialog = function() { 
    $myWindow.dialog("close"); 
    } 
    </script> 
    

답변

0

당신은 두 가지 선택이있다. 이 같은 jQuery를 load 방법을 통해 양식을 제출

0

시도 :

$("#myDiv").load("your_submit_page_url_here", $("#yourFormIdHere").serializeArray()); 

serializeArray 방법은 load 방법을 받아들이는 JSON 형식으로 양식 내용을 변환합니다. 전체 호출은 기본적으로 myDiv에 제출 한 후 결과 페이지의 콘텐츠를로드합니다. 은 귀하가 <form> 태그를 부여한 ID입니다.

관련 문제