确认转推

I'm making a script that when a user clicks a button a popup box displays with a text box of the tweet and a button for the user to retweet what's in the text box. In the script it's suppose to tell the user if it has retweeted successfully. The thing is that it tells the user it's successfully retweeted before the user has clicked the retweet button in the pop up box.

Seems as though just by clicking the button that activates the pop up box display is when the code activates a successful retweet message though nothing has been retweeted on the users end.

I'm not very familiar with javascript, my guess it's not the php code that's making the faulty logic but the javascript code. Here is what I have below.

    (function($) {
    $(document).ready(function() {
        $.getScript("http://platform.twitter.com/widgets.js", function(){
            twttr.events.bind('tweet', function(event) {
                var targetUrl = event.target.src;
                var query = getQueryParams(targetUrl);
                click_callback(query.url);
            });
        });
    });
    })(jQuery);

    function getQueryParams(qs) {
        qs = qs.split("+").join(" ");
        var params = {}, tokens,
            re = /[?&]?([^=]+)=([^&]*)/g;
        while (tokens = re.exec(qs)) {
            params[decodeURIComponent(tokens[1])]
                = decodeURIComponent(tokens[2]);
        }
        return params;
    }

    function click_callback(id){
        var user = "<? echo $data->id;?>";
        document.getElementById("Hint").style.display='block';
        $("#Hint").html('Confirming Tweet...');
        $.ajax({
            type: "POST",
            url: "plugins/rt/complete.php",
            data: "id="+ id + "&user=" + user,
            success: function(msg){
                $("#Hint").html('Tweeted! Success!');
                removeElement('boxes', id);
            }
        });
    }

    function removeElement(parentDiv, childDiv){
        if (document.getElementById(childDiv)) {     
            var child = document.getElementById(childDiv);
            var parent = document.getElementById(parentDiv);
            parent.removeChild(child);
        }
    }

I think this is what's causing it within the code:

  function click_callback(id){
            var user = "<? echo $data->id;?>";
            document.getElementById("Hint").style.display='block';
            $("#Hint").html('Confirming Tweet...');
            $.ajax({
                type: "POST",
                url: "plugins/rt/complete.php",
                data: "id="+ id + "&user=" + user,
                success: function(msg){
                    $("#Hint").html('Tweeted! Success!');
                    removeElement('boxes', id);
                }
            });
        }