$(document).ready(function(){
/* fetch elements and stop form event */
var submitData = $("form.follow-form").submit(function (e) {
/* stop event */
e.preventDefault();
/* "on request" */
$(this).find('i').addClass('active');
/* send ajax request */
$.ajax({
type: "POST",
url: "recycle.php",
data: submitData,
dataType: "html",
success: function(msg){
if(parseInt(msg)!=0)
{
/* find and hide button, create element */
$(e.currentTarget)
.find('button').hide()
.after('<span class="following"><span></span>Recycled!</span>');
}
}
});
});
});
I think there is an error in this jquery syntax and or it could be my php code, I cant seem to find it!!
this is the recycle.php
<?php session_start();
include_once ('includes/connect.php');
$id = $_POST['id'];
$tweet =$_POST['tweet'];
mysql_query("INSERT INTO notes SET user_note='".$_POST['tweet']."',dt=NOW(),recycle_id='".$id."', user_id = '".$_SESSION['user_id']."' ");
?>
and this is the html code
<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>
Your use of
submitDatalooks strange to me. You don’t have to declare that variable and it will not contain the data of the form (I thinksubmit()returns nothing, sosubmitDatawould beundefined).I think you have to do:
Reference:
.serialize()