所以我看到這篇文章幫助解答了我的問題的一部分,但現在我的表單仍然不使用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