简体   繁体   English

这个jQuery帖子有什么问题吗?

[英]there is something wrong with this Jquery post?

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! 我试图将id属性传递给file.php,但是每次我尝试将其插入数据库时​​,它都会给我0,提供了javascript和html!

$(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: html文件:

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

ps it deos insert the value in the database ps它deos将值插入数据库

file.php: file.php:

<?php

$id =$_POST['id'];

msql_insert.........
?>

在这种情况下可能没有关系,但是元素的ID不应以数字开头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM