세이버로 작성된 후에 실행되지 않습니다. 너는 균열 같아. 수정이 필요할 때 나는 당신에게 간다 ... 사용자가 양식을 제출하기 전에 jQuery 대화 상자를 사용하여 내용을 확인하는 주석 처리 시스템을 제출해야한다.두 번째 호출 jQuery 대화 상자가 ajax
첫 번째 문제는 없습니다. 대화 상자가 정상적으로 실행되고 양식이 제출됩니다. 다시 게시하려고하면 Ajax 호출이 실패하고 대화 상자가 표시되지 않으며 기본 양식이 제출됩니다.
대화 상자는 양식의 성공적인 아약스 생성에 바인딩되어 있으므로 바인딩이 있어야하지만 확실하게 누락되었습니다.
다음은 코드입니다.
첫 번째 아약스 호출은 의견을 게시하는 양식을 가져옵니다. 성공적으로로드되면 사용자가 양식을 제출하려고 할 때 호출 할 대화 상자를 시작합니다.
// Make the ajax call for the apppropriate content.
$.ajax({
type: 'Get',
url: 'a/url/to/process/form',
cache: false,
beforeSend: function() {
},
success: function(data) {
$('#commentBox_' + id).html(data).fadeTo('fast', 100);
$('#' + oId).addClass('remove').removeClass('respond').html('Close');
// Destroy the instance if it has already been called.
if(CKEDITOR.instances['comment'])
{
delete CKEDITOR.instances['comment'];
}
$('#discussionComment_' + id).submit(function() {
CKupdate()
});
// Set the editor.
CKEDITOR.replace('comment', {toolbar : 'Basic', skin : 'Office2003', height : 250})
// Set the submit option.
$('#postComment_' + id).live('click', function() {
// Warn the user about submitting. Let them review their comment.
CKupdate() // Update the field with user input content.
$('.ui-dialog-content').dialog("destroy"); // Get rid of any old dialogs lurking around.
// Get the content from the form for the confirmation dialog
var commentTitle = $('#commentSubject_' + id).val();
var commentBody = CKEDITOR.instances['comment_' + id].getData();
// Build the new dialog.
var NewDialog = $('<div>You are about to submit your comment. Verify before submitting.<hr /><h4>' + commentTitle + '</h4><div>' + commentBody + '</div></div>');
$(NewDialog).dialog({
modal: true,
title: 'Confirm Post',
width: 500,
buttons: {
'Submit': function() {
commentPost_ajax(id); // Post the form via ajax.
$(this).dialog('destroy');
},
'Edit': function() {
$(this).dialog('destroy');
return false; // Don't submit the form.
}
}
});
return false;
});// Click to submit form.
},
error: function() {
window.location = "../../post_discussionComment.html?dId<%=dId%>&id=" + id
}
});
// Stay here. We're just starting to have fun.
return false;
다음은 아약스 게시물 기능입니다.
function commentPost_ajax(id) {
// Just close and submit.
$('#discussionComment_' + id).ajaxSubmit({
beforeSend: function() {
$('#discussionComment_' + id + ' input:submit').html('Sending...');
$('#newEntry').attr('id', '');
},
success: function(data) {
$('#commentBox_' + id).after(data);
$('#discussionComment_' + id).remove();
$('#discussionComment_' + id).hide('puff', function() { $(this).remove() }, 'fast');
$('#content_' + id + ' a.remove').removeClass('remove').addClass('respond').html('Respond');
$('.expand').show();
window.location + $('#newEntry');
$('#newEntry').children().effect("highlight", {}, 3000);
},
error: function() {
alert('There was a problem posting your comment. Please try again.');
}
}); // Form submit
}
아무 도움이됩니다. 나는 많은 다른 질문을 봤는데, 그들 중 누구도 직접이 말을하지 않습니다. 그들이 찾으면 나는 그들을 찾을 수 없었다.
잘 모르겠지만 여기에 견적이 누락되었습니다. 'url :'/ url/to/process/form, '<--- –
감사하지만 복사 및 붙여 넣기 오류입니다. . 나는 진짜 URL을 뽑았다. – edumacator
'id'는 어디에서 파생 되었습니까? 그리고 $ ('discussionComment_'+ id) .remove();를하면 DOM에서 요소를 제거하므로 다음 행'$ ('# discussionComment_ '+ id) .hide ('puff ', function() {$ (this) .remove()},'fast '); – Ohgodwhy