首先是我的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
alert(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
});
我的voteup.php文件文件是:
<?php
$id=$_POST['itemID'];
echo '<h2>PHP Response: You voted post '.$id.' up</h2>';
?>
然而,它似乎没有工作,警报通过后ID,但从那时起什么也没有。$id没有回音。
有什么想法吗?