如何通过链接进行AJAX请求?

我试图在我的网站上建立一个删除评论链接,类似于通过Twitter设置评论的链接。这样的话,用户不必离开页面,就可以让保留该评论的div消失。我知道我必须通过AJAX进行此操作,但我仍在学习中。到目前为止,这是我设置的内容,但是每次单击链接时,都不会发生任何变化。

$(document).ready(function() {
    $('.delete_post').click(function () {                       
        var id = $(this).attr('id');
        var data = 'id=' + id.val() + '&submit=yes';
        alert(id);
        //start the ajax
        $.ajax({
            url: "<?php echo $url; ?>/process_form/delete_post.php",    
            type: "GET",        
            data: data,        
            cache: false,
            success: function (html) {                
                if (html==1) {  
                    document.getElementById(id).style.display = 'none';                 
                } 
                else {
                    alert("Post was not deleted");
                }              
            }        
        });
        return false;
    });
}); 

<a href="#" class="delete_post" id="dp<?php echo $comment["id"]; ?>">Delete</a>

你们可以提供一些建议吗? 非常感谢。

.attr() returns a string.
Change the data part to this and it should work

var id = $(this).attr('id');
var data = 'id=' + id + '&submit=yes';

How about Net in Firebug? You can get your post and output in there. Any why not use the absolute url?

url: "mysite.com/process_form/delete_post.php",