我正在尝试通过 jQuery 发布表单.post()
,但它无法正常工作。我没有从控制台得到任何东西,这非常令人沮丧。向有经验的 JS 用户请求帮助。非常感谢您的所有帮助!
注意:这个表单是用 CodeIgniter 构建的,并且使用它的表单助手和 HTML 常规路由可以完美地发布。JS/jQuery 方法不能正常工作。
形式:
<form class="nice custom" id="create_form">
<h3>Create Event</h3>
<label for="intention"><strong>Intention:</strong></label>
<?php $intention_attributes='style="width: 100%; " class="show-on-phones" id="intention_dropdown"'; ?>
<?php echo form_dropdown('intention', $intention, 'Select Intention', $intention_attributes ); ?>
<div class="custom dropdown show-on-desktops" style="width: 100%; ">
<a href="#" class="current">Select Intention</a>
<a href="#" class="selector"></a>
<ul style="width: 100%; ">
<li>Select Intention</li>
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
<li>Option 4</li>
<li>Option 5</li>
</ul>
</div>
<label for="action"><strong>Action:</strong></label>
<?php echo form_input($action); ?>
<label for="date_of_event"><strong>Date:</strong></label>
<?php echo form_input($date_of_event); ?>
<label for="repeat_event"><strong>Repeat:</strong></label>
<?php $repeat_event_attributes='style="width: 100%; " class="show-on-phones" id="repeat_event_dropdown"'; ?>
<?php echo form_dropdown('repeat_event', $repeat_event, 'Never', $repeat_event_attributes); ?>
<div class="custom dropdown show-on-desktops" style="width: 100%; ">
<a href="#" class="current">Never</a>
<a href="#" class="selector"></a>
<ul style="width: 100%; ">
<li>Never</li>
<li>Every Day</li>
<li>Every Week</li>
<li>Every Two Weeks</li>
<li>Every Month</li>
<li>Every year</li>
</ul>
</div>
<label for="end_repeat_event"><strong>End Repeat:</strong></label>
<?php echo form_input($end_repeat_event); ?>
<br />
<input style="width: 100%; " type="submit" name="submit" class="medium radius blue button" value="Create" id="create_button" />
</form>
JavaScript:
// Submit Create Form
$('#create_form').live('submit', function() {
var data = $('#create_form').serialize();
var url = $(this).attr('action');
$.post(url, data, function() {
document.location.reload();
});
return false;
}); // End