所以我看到这篇文章帮助解答了我的问题的一部分,但现在我的表单仍然不使用jQuery来发布表单。使用jQuery从表单打开标记
How to remove the action attribute in the form_open_multipart() in Codeigniter?
这是当网页打开所呈现的HTML和PHP的标签,使得它。
<?php $attributes = array('class' => 'validate', 'id' => 'pmForm'); ?>
<?php echo form_open('', $attributes); ?>
<form id="pmForm" class="validate" accept-charset="utf-8" method="post" novalidate="novalidate">
* Validate the form when it is submitted
*/
var validateform = $("#pmForm").validate({
invalidHandler: function(form, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
var message = errors == 1
? 'You missed 1 field. It has been highlighted.'
: 'You missed ' + errors + ' fields. They have been highlighted.';
$('.box .content').removeAlertBoxes();
$('.box .content').alertBox(message, {type: 'warning', icon: true, noMargin: false});
$('.box .content .alert').css({
width: '100%',
margin: '0',
borderLeft: 'none',
borderRight: 'none',
borderRadius: 0
});
} else {
$('.box .content').removeAlertBoxes();
}
},
showErrors : function(errorMap, errorList) {
this.defaultShowErrors();
var self = this;
$.each(errorList, function() {
var $input = $(this.element);
var $label = $input.parent().find('label.error').hide();
$label.addClass('red');
$label.css('width', '');
$input.trigger('labeled');
$label.fadeIn();
});
},
submitHandler: function(form) {
var dataString = $('#pmForm').serialize();
$.ajax({
type: 'POST',
url: '/path/to/my/php/submitfunction',
data: dataString,
dataType: 'json',
success: function(data) {
if (data.error) {
$('.box .content').removeAlertBoxes();
$('.box .content').alertBox(data.message, {type: 'warning', icon: true, noMargin: false});
$('.box .content .alert').css({
width: '',
margin: '0',
borderLeft: 'none',
borderRight: 'none',
borderRadius: 0
});
}
else
{
$('.box .content').removeAlertBoxes();
$('.box .content').alertBox(data.message, {type: 'success', icon: true, noMargin: false});
$('.box .content .alert').css({
width: '',
margin: '0',
borderLeft: 'none',
borderRight: 'none',
borderRadius: 0
});
$(':input','#pmForm')
.not(':submit, :button, :hidden, :reset')
.val('');
}
}
});
}
});
任何想法,为什么它不使用jQuery发布?
仍试图找出如何处理这个问题?
后呈现的HTML,这里是jQuery代码 – Rafay 2012-03-27 16:38:19
哎呀对不起忘了,包括它。 – 2012-03-27 16:53:36
信息已更新 – 2012-03-27 16:55:35