2015-01-21 3 views
0

작업 할 진행률 막대를 얻으려는 양식이 있습니다. 이 양식은 joomla에 있으며 파일 업로드시기를 표시하는 Ajax 진행 표시 줄을 얻을 수있었습니다. 그러나 양식의 일반적인 습관은 양식을 제출할 때 양식이 연관된 항목 페이지로 이동하고 해당 페이지에 확인 된 내용이 저장되었음을 알려주는 것입니다.Ajax 양식 진행 리디렉션

그러나이 새로운 Ajax 진행 막대를 사용하면 막대가 100 %로 표시되고 방화 광구를 보면 POST와 GET 모두 성공했지만 문제는 브라우저가 원본 페이지로 리디렉션하지 않고 양식 페이지에 남아 있다는 것입니다. 동일한 GET URL?

은 다음 코드의 일부가 될 때 다음 custom.js

$(document).ready(function() 
{ 

    $('#item_file').change(function(){ 
     $('#submit').removeAttr('disabled'); 
    }); 

    $('#submit').change(function(){ 
     $('#progress').removeClass('hide'); 
    }); 


    var options = { 

    beforeSend: function() 
    { 
     $("#progress").show(); 
     //clear everything 
     $("#bar").width('0%'); 
     $("#message").html(""); 
     $("#percent").html("0%"); 
    }, 

    uploadProgress: function(event, position, total, percentComplete) 
    { 
     $("#bar").width(percentComplete+'%'); 
     $("#percent").html(percentComplete+'%'); 

    }, 

    success: function() 
    { 
     $("#bar").width('100%'); 
     $("#percent").html('100%'); 

    }, 

    complete: function(response) 
    { 
     $("#message").html("<font color='green'>"+response.responseText+"</font>"); 
    }, 

    complete: function() 
    { 

    }, 

    error: function() 
    { 


    } 

}; 

    $("#idForm").ajaxForm(options); 
}); 

에서 다음

JHTML::_('behavior.mootools'); 
    JHTML::_('behavior.formvalidation'); 

    $document =& JFactory::getDocument(); 

    $document->addScript('components/com_component/assets/validate.js'); 
    $document->addScript('jquery-1.7.js'); 
    $document->addScript('jquery.form.js'); 
    $document->addScript('custom.js'); 

    <form action="index.php" method="post" name="nameForm" id="idForm" enctype="multipart/form-data" class="form-validate"> 
<input type="file" name="item_file" id="item_file"/></td> 

기본 동작 또는 리디렉션 그래서 나는 custom.js에 추가 할 수있는 일이 있나요 업로드 진행률 표시 줄이 완료되면 계속됩니다.

감사합니다.

+0

* font * 요소를 사용하셨습니까? 예. – epascarello

+0

성공하면 페이지를 리디렉션 하시겠습니까? 그러므로 성공 또는 완료 메소드에서 window.location.href를 설정하십시오. – epascarello

답변

0
대상 페이지로 이동 아약스의 성공 호출에 변경

: 나는이 같은 문제가 없었다

success: function() 
    { 
     $("#bar").width('100%'); 
     $("#percent").html('100%'); 
     //Go to new page 
     window.location.href= 'index.php'; 

    }, 
+0

감사합니다. 리디렉션을하지만 양식이 연결된 항목 페이지가 아니라 웹 사이트 루트에 있습니다. 제출을 클릭하고 진행이 끝나면 직후에 firebug ..로 표시된 GET url이 있습니다. 'index.php? option = com_component & view = item & id = 38'이것은 리디렉션되어야 할 URL입니다. 어떻게 가능할까요? – nrider

+0

또한 URL은 항상 다른 항목과 다른 양식으로 다르므로 window.location.href = 'index.php? option = com_component & view = item & id = 38' ; – nrider

+0

URL에서 쿼리 매개 변수를 만들기 위해 필요한 데이터를 서버에서 클라이언트로 전송하십시오. 그러면 success - function (data) {// 서버에서 오는 데이터 객체의 데이터를 기반으로 리디렉션 URL을 구성합니다. – spooky

0

, 나는 그것을 해결했다. 100 % 작동

)

행동 = "자바 스크립트 : 무효 (0)"추가

양식에

하고

창을 사용합니다. location.href

은 아약스의 성공을 뒷받침합니다.