我正在尝试使用 jquery 来运行 php 文件。php 将一些信息发送到数据库。
php 本身可以工作。我可以删除 js 代码并将所有内容发送到数据库。从我的数据库中可以明显看出发生了什么。未收集表单中的内容。有些东西进入数据库,但不是来自表单的信息。
这是我的代码,可能是什么问题?
// submit without refresh
$(function() {
$('#form').submit(function(e) {
// Stop the form actually posting
e.preventDefault();
// Send the request
$.post('submit.php', {}, function(d) {
console.log(d);
// Here we handle the response from the script
// We are just going to alert the result for now
alert(d);
});
});
});
我的表单有id="form"
为什么js不收集表单信息?