現在、http: //jsfiddle.net/xSkgH/47/にある複数ステップのクエリ フォームに取り組んでいます。
jQuery AJAX (process.php が処理を処理します) を介して変数を送信し、 resultと呼ばれる process.php の div を使用して最後のステップでdiv を更新しようとしています。どうすればこれを達成できますか?
これまでのところ、malsup (http://jquery.malsup.com/form/) による jQuery フォーム プラグインを使用してこれを達成できましたが、厳密な仕様の一部としてそれを達成するために jQuery AJAX メソッドを使用する必要があります。
これは私が使用していたコードです(jQueryフォームプラグインを使用):
// prepare the form when the DOM is ready
$(document).ready(function() {
var options = {
target: '#result',
beforeSubmit: showRequest,
success: showResponse
};
// bind to the form's submit event
$('#task5_booking').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
});
// pre-submit callback
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
// alert('About to submit: \n\n' + queryString);
}
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
$('#last-step').fadeOut(300, function() {
$('#result').html(responseText).fadeIn(300);
});
}
どうもありがとう!