我有一个jquery post方法,它将姓名、密码和电子邮件发送到register.php
function postData()
{
thisBtn = $(this);
parent = $(this).parent();
name = parent.data('name');
password = parent.data('password');
email =parent.data('email');
$.post('register.php', {name: (name), password: (password), email: (email)}, function(data) ;
parent.next('#message').html(data);
}执行onclick功能的按钮:
<button onclick = 'postData()' class='regular' name='save'>但是,当按下按钮时,似乎没有任何反应
发布于 2012-02-23 02:57:06
你有两个选择...
在onclick中传递和对象:
<button onclick='postData(this)' class='regular' name='save'>或者在使用jQuery时使用jQuery首选方法附加单击处理程序:
$('input[name="save"]').click(function() {
// your post code here
}};这样就不需要onclick='postData(this)'了。
https://stackoverflow.com/questions/9401110
复制相似问题