views:

46

answers:

1

im trying to pass on the id attribute to the file.php, but its giving me 0 every time, when i try to insert it into the database, the javascript and the html is provided!

$(function() {
      $(".follow").click(function(){
        var element = $(this);
        var I = element.attr("id");
        var info = 'id=' + I;

        $.ajax({
            type: "POST",
            url: "file.php",
            data: info,
            success: function(){}
            });

        $("#follow"+I).hide();
        $("#remove"+I).show();
        return false;

      });
});

html file:

<div id="follow1"><a href="#" class="follow" id="1"><span class="follow_b"> Follow </span></a></div>

p.s. it deos insert the value in the database

file.php:

<?php

$id =$_POST['id'];

msql_insert.........
?>
+1  A: 

It may not matter in this case, but the ID of an element is not supposed to start with a number.

babtek
isit? confused sorry lol
getaway
@getaway - You have your <a> tag having an ID of 1 (one). That will blow up on you.
JasCav
oh okay, then thanks
getaway
got it all sorted out, thank you, thier was a problem with the php script!!! thanks for trying
getaway