【发布时间】:2014-02-26 14:46:20
【问题描述】:
我有一个简单的表单,我试图通过 jQuery 提交。就是这样:
<form id="turn_conf" action='turn_insert.php' method="POST">
<label for="nombre">Nombre:</label>
<input type="text" id="tu_name" name="tu_name">
<input type="submit" class="botonEnvio" value="Crear">
</form>
还有一个 jQuery 函数,目前似乎无法正常工作,屏幕上也不会显示“似乎我正在工作”警报
$('#turn_conf').on('submit', validaDatos)
function validaDatos(e) {
var nombreTurno = $('input[name=tu_name]').val();
$.post({url: $(this).attr('action'),
data: { tu_name:nombreTurno },
success:feedback })
e.preventDefault(); }
function feedback (datos) {
alert("Seems I'm working!")}
没有值被插入到 DDBB。这里有插入 PHP 文件“turn_insert.php”的内容:
$nombreTurno = $_POST['tu_name'];
$insertar = mysql_query("INSERT INTO turn_conf (tu_id,tu_name,tu_status) VALUES ('','$nombreTurno','1')");
控制台显示错误:控制台错误:POST localhost/Gestion/%5Bobject%20Object%5D 404 Not Found
关于这里出了什么问题有什么建议吗?提前谢谢你。
【问题讨论】:
-
控制台有错误吗?
-
嗨@hemanth。不,在加载或提交表单时也不行。谢谢。
-
对不起@hemanth,是的,我在控制台上确实有这个错误:POST localhost/Gestion/%5Bobject%20Object%5D 404 Not Found - 对不起。
标签: php jquery html forms insert