jQuery(function ($) {
/* fetch elements and stop form event */
$("form.follow-form").submit(function (e) {
/* stop event */
e.preventDefault();
/* "on request" */
$(this).find('i').addClass('active');
/* send ajax request */
$.post('recycle.php', {
followID: $(this).find('input').val()
}, function () {
/* find and hide button, create element */
$(e.currentTarget)
.find('button').hide()
.after('<span class="following"><span></span>Following!</span>');
});
});
});
html:
<form class="follow-form" method="post" action="recycle.php">
<input name="id" value="$id" type="hidden">
<input name="$tweet" value="$tweet" type="hidden">
<button type="submit" value="Actions" class="btn follow" title="123456">
<i></i><span>recyle</span>
</button>
</form>
reycle.php:
<?php session_start();
include_once ('includes/connect.php');
$id = $_POST['id'];
$tweet =$_POST['tweet'];
$registerlistener = mysql_query("INSERT INTO notes (user_id, user_note,recyle_id,dt) VALUES('".$_SESSION['user_id']."','".$tweet."','".$id."',NOW()");
?>
问题是它没有访问recycle.php文件,该文件将html表单中的信息插入到数据库中!但它正在做整个jquery动画!!我不知道这是什么问题!!!
答案 0 :(得分:0)
使用firebug控制台或类似的东西,看看是否有任何404
或其他错误。如果您没有看到任何404错误,请检查您的php
脚本。
答案 1 :(得分:0)
您的语法看起来确实很好,尝试将回调变量添加到签名
中答案 2 :(得分:0)
var_dump()
php脚本中的$_POST
变量,并使用firebug检查响应(Firefox扩展名)。通过这种方式,您可以看到通过的内容。
但我认为您的数据收集存在问题。 这可能有效:
$.post('recycle.php', {
id: $(this).find('input[name=id]').attr('value'),
tweet: $(this).find('input[name~=tweet]').attr('value')
},
function(response){
//on success code
});
您可以使用firebug日志记录(console.log
)或var_dump
结果进行确认。