views:

32

answers:

3
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>');
        });
    });
});

the 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()");



?>

the problem is that it's not accessing the recycle.php file, which inserts the information from the html form into the database! but it's doing the whole jquery animation!! i dont see whats the problem!!!

A: 

Use firebug console or something similar and see if there are any 404or other errors. If you don't see any 404 errors, check if your php script.

Teja Kantamneni
ive added the php scirpt, its not adding nothing to the database
getaway
Check the logic and what going on in the PHP script. A debugging effort can help a lot.
Teja Kantamneni
A: 

Your syntax certainly looks fine, try adding the variables for the callback into the signature

El Guapo
sorry i dnt get what u mean, im a bit of a newbie here
getaway
A: 

var_dump() the $_POST variable in your php script and check the response with firebug (Firefox extension). This way you can see what gets through.

But i think there is a problem with your data collecting. This might work:

$.post('recycle.php', {
   id: $(this).find('input[name=id]').attr('value'),
   tweet: $(this).find('input[name~=tweet]').attr('value')
   },
   function(response){
   //on success code
   });

You can confirm this either with firebug logging (console.log) or with var_dump results.

Ali Sattari