0
안녕하세요 저는 jFormer 라이브러리를 Wordpress에 통합하고 WordPress에 Ajax 호출로 걸림돌을 치고 있습니다. 나는 워드 프레스 아래 플러그인 내 아약스 투수를 등록 :jQuery 양식 추가 게시물 변수 보내기 AJAX
add_action('wp_ajax_nopriv_jFormerForWp', 'JFormerForWP::AjaxHandler');
add_action('wp_ajax_jFormerForWp', 'JFormerForWP::AjaxHandler');
은 본질적으로 내가 뭘해야 => POST 요청에 jFormerForWp을 변수라는 조치를 보낼 수 있습니다.
문제는 jQuery 기술이 제한되어 있기 때문에 개발자에게 물어 보았습니다. 가능할 때 제게 돌아올 수는 있지만 일반적인 jQuery 커뮤니티에 도움을 줄 수 있다고 생각했습니다.
확인하려면 action = jFormerForWp를 보내려면 jQuery 코드를 수정해야합니다.
코드는 여기에 http://www.jformer.com/download/jFormer-dev.zip 아래 발췌 부분과 함께 요청이 양식에 의해 만들어진 것 같아요. 많은 감사합니다, 크리스이 후
submitForm: function(event) {
var self = this;
// Use a temporary form targeted to the iframe to submit the results
var formClone = this.form.clone(false);
formClone.attr('id', formClone.attr('id')+'-clone');
formClone.attr('style', 'display: none;');
formClone.empty();
formClone.appendTo($(this.form).parent());
// Wrap all of the form responses into an object based on the component jFormComponentType
var formData = $('<input type="hidden" name="jFormer" />').attr('value', encodeURI(jFormerUtility.jsonEncode(this.getData()))); // Set all non-file values in one form object
var formIdentifier = $('<input type="hidden" name="jFormerId" value="'+this.id+'" />');
formClone.append(formData);
formClone.append(formIdentifier);
this.form.find('input:file').each(function(index, fileInput) {
if($(fileInput).val() != '') {
// grab the IDs needed to pass
var sectionId = $(fileInput).closest('.jFormSection').attr('id');
var pageId = $(fileInput).closest('.jFormPage').attr('id');
//var fileInput = $(fileInput).clone()
// do find out the section instance index
if($(fileInput).attr('id').match(/-section[0-9]+/)){
var sectionInstance = null;
var section = $(fileInput).closest('.jFormSection');
// grab the base id of the section to find all sister sections
var sectionBaseId = section.attr('id').replace(/-section[0-9]+/, '') ;
sectionId = sectionId.replace(/-section[0-9]+/, '');
// Find out which instance it is
section.closest('.jFormPage').find('div[id*='+sectionBaseId+']').each(function(index, fileSection){
if(section.attr('id') == $(fileSection).attr('id')){
sectionInstance = index + 1;
return false;
}
return true;
});
fileInput.attr('name', fileInput.attr('name').replace(/-section[0-9]+/, '-section'+sectionInstance));
}
// do find out the component instance index
if($(fileInput).attr('id').match(/-instance[0-9]+/)){
// grab the base id of the component to find all sister components
var baseId = $(fileInput).attr('id').replace(/-instance[0-9]+/, '')
var instance = null;
// Find out which instance it is
$(fileInput).closest('.jFormSection').find('input[id*='+baseId+']').each(function(index, fileComponent){
if($(fileComponent).attr('id') == $(fileInput).attr('id')){
instance = index + 1;
return false;
}
return true;
});
fileInput.attr('name', $(fileInput).attr('name').replace(/-instance[0-9]+/, '-instance'+instance));
}
$(fileInput).attr('name', $(fileInput).attr('name')+':'+pageId+':'+sectionId);
$(fileInput).appendTo(formClone);
}
});
// Submit the form
formClone.submit();
formClone.remove(); // Ninja vanish!
// Find the submit button and the submit response
if(!this.options.debugMode){
this.controlNextButton.text(this.options.submitProcessingButtonText).attr('disabled', 'disabled');
}
else {
this.form.find('iframe:hidden').show();
}
},
감사 Vibhu, 나는 다른 아약스 함수 호출 주위에 당신이 저를 설정 한 도움을 주셔서 감사 엉망으로했다 궤도에. – g18c