我试图通过jQuery发布表单.post()
,而且它不能正常工作。我没有从控制台中获得任何东西,而且非常令人沮丧。向有经验的JS用户请求帮助。非常感谢您的帮助!通过jQuery发布表单 - 没有控制台错误
NOTE:这个表格是用CodeIgniter构建的,并且使用Form Helper和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
什么是“不工作”?如果您观看网络流量(例如使用IE9开发人员工具等),您是否看到通过线路发送的请求?该请求的HTTP响应代码是什么? –
你的'
向我们展示PHP处理后存在的表单更有帮助。 – Sampson