Javascript 通过jQuery发布过账表单-无控制台错误
我试图通过jQueryJavascript 通过jQuery发布过账表单-无控制台错误,javascript,jquery,ajax,forms,Javascript,Jquery,Ajax,Forms,我试图通过jQuery.post()发布表单,但它没有正常工作。我没有从控制台得到任何东西,这很令人沮丧。请求有经验的JS用户提供帮助。非常感谢你的帮助 注意:此表单是使用CodeIgniter构建的,并使用其表单助手和HTML常规路径完美发布。JS/jQuery方法无法正常工作 表格: <form class="nice custom" id="create_form"> <h3>Create Event</h3&
.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>
// 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
您的表单没有操作值:
<form class="nice custom" id="create_form">
另外,从现在开始,避免使用$.live
:
从jQuery1.7开始,不推荐使用.live()
方法。使用.on()
附加事件处理程序。较旧版本的jQuery用户应优先使用.delegate()
,而不是.live()
-
您的表单没有操作值:
<form class="nice custom" id="create_form">
另外,从现在开始,避免使用$.live
:
从jQuery1.7开始,不推荐使用.live()
方法。使用.on()
附加事件处理程序。较旧版本的jQuery用户应优先使用.delegate()
,而不是.live()
-
尝试将提交按钮的名称更改为btnSubmit。我过去在命名submit按钮submit时遇到过一些问题
谢谢,尝试将“提交”按钮的名称更改为btnSubmit。我过去在命名submit按钮submit时遇到过一些问题
谢谢,另外,请按console输出选项卡顶部的黑点按钮(webkit浏览器)。这将在页面加载之间保留日志消息。此外,按下控制台输出选项卡顶部的黑点按钮(webkit浏览器)。这将在页面加载之间保留日志消息。什么是“不工作”?如果您观察网络流量(例如使用IE9开发工具等),您是否看到通过网络发送的请求?该请求的HTTP响应代码是什么?您的
没有操作。我不记得这在您的语句中是如何解析的:var url=$(this.attr('action')
可能显式添加操作会修复它。在处理PHP后向我们显示表单的存在状态更有用。此表单和CodeIgniter表单之间唯一的变化是
是什么“不起作用”?如果您观察网络流量(例如使用IE9开发工具等),您是否看到通过网络发送的请求?该请求的HTTP响应代码是什么?您的
没有操作。我不记得这在您的语句中是如何解析的:var url=$(this.attr('action')
可能显式添加操作将解决此问题。在处理PHP后向我们显示表单的现有状态更有用。此表单与CodeIgniter表单之间唯一的变化是
是,感谢您提供有关.live()
和.on()
的提示。我将从现在开始实施。我将删除“.attr('action');看看这能否解决问题。这是一个旧版本的表单。我在你的帮助下解决了这个问题。非常感谢你!感谢您提供有关.live()
和.on()
的提示。我将从现在开始实施。我将删除“.attr('action');看看这能否解决问题。这是一个旧版本的表单。我在你的帮助下解决了这个问题。非常感谢你!