2012-04-16 2 views
0

안녕하세요. 다단계 양식에 jQuery AJAX를 통합하여 process.php 페이지의 특정 div를 업데이트하지만 결과를 새 페이지. 페이지를 새로 고치지 않고 div를 업데이트하려면 어떻게해야합니까? http://jsfiddle.net/xSkgH/47/ :다단계 양식의 jQuery 아약스

$.ajax({ 
    url: 'process.php', 
    data: $('form[name="booking"]').serialize(), 
    dataType: 'html', 
    type: 'POST', 
    success: function(data) { 

     // this is the bit that needs to update the div 

     $('#last-step').fadeOut(300, function() { $('#result').html(data).fadeIn(300); 
    }, 
    complete: function (data) { 
     // your code here 
    }, 
    error: function (url, XMLHttpRequest, textStatus, errorThrown) { 
     alert("Error: " + errorThrown); 
    } 
}); 

이 내 다단계 형태의 코드는 다음과 같습니다

이것은 내가 사용하고있어 jQuery 코드입니다. 사전에

많은 감사

답변

1

나는 사업부는 마크 업에 result라고 볼니까. 따라서 아마도 마지막 div에 결과를 표시해야 할 것입니다. 그리고 누락되었습니다 })도 있습니다. 아래 코드는 작동해야합니다.

$.ajax({ 
    url: 'process.php', 
    data: $('form[name="booking"]').serialize(), 
    dataType: 'html', 
    type: 'POST', 
    success: function(data) { 

     // this is the bit that needs to update the div 

     $('#last-step').fadeOut(300, function() { 
       $('#last-step').html(data).fadeIn(300); 
     }); 
    }, 
    complete: function (data) { 
     // your code here 
    }, 
    error: function (url, XMLHttpRequest, textStatus, errorThrown) { 
     alert("Error: " + errorThrown); 
    } 
}); 
+0

결과 div는 process.php 파일에 저장됩니다. 나는 당신의 코드를 테스트했고, 같은 문제를 반환하는 것 같다. 결과가 새 페이지에 나타나고 div가 업데이트되지 않습니다. 내가 뭘 잘못하고 있는지 모르겠다. – CJS

+0

process.php는 아약스 요청을 처리하는 서버 페이지입니다. 그래서 클라이언트 화면 (폼이있는 페이지)의 div로 결과를 업데이트해야합니다. 다른 스크립트 오류가 없는지 확인하십시오. 제출 버튼을 클릭하고 있습니까? – Shyju

+0

이것은 모든 양식 clientside를 만들어야한다는 것을 의미합니까? 사업부조차도? – Tom