开发者

jQuery - Post and reply

开发者 https://www.devze.com 2023-01-13 18:05 出处:网络
Im attempting to add voteup/votedown to one of my sites, however Im having a few problems: Firstly here is my jQuery:

Im attempting to add voteup/votedown to one of my sites, however Im having a few problems:

Firstly here is my jQuery:

j(".voteup").click(function(){ // when people click an up button
  j("div#response").show().html('<h2>voting, please wait...</h2>'); // show wait message
    itemID = j(this).parent('div').attr('id');; // get post id
    aler开发者_运维知识库t(itemID);

    j.post(voteup.php,{id:itemID},function(response){ // post to up script
      j("div#response").html(response).hide(3000); // show response
  });

  j(this).attr({"disabled":"disabled"}); // disable button
});

My voteup.php file is:

<?php

$id=$_POST['itemID'];

echo '<h2>PHP Response: You voted post '.$id.' up</h2>';

?>

However It doesnt appear to be working, the alert comes through with the post ID but nothing from then on. The $id doesnt get echo'd.

Any ideas?


you must wrote

$id=$_POST['id'];

instead of

$id=$_POST['itemID'];

in voteup.php


I think if you can use json instead of html will be much good but i have a ready to use solution. hope meet your requirement.

http://ad1987.blogspot.com/2009/02/reddit-style-voting-with-php-mysql-and.html demo is http://cyberbuff.noadsfree.com/lab/reddit_votes/

0

精彩评论

暂无评论...
验证码 换一张
取 消