$(function()
{
    /*
     * ユーザ画面: ニュース管理にて使用
     */

    // 参考になったリンクを押下
    $("a[@name='clap']").click(function()
    {

        var news_id = $("input[@name='news_id']").val();
        if (!news_id) {
//            alert('投票できませんでした。');
            return false;
        }

        // リクエストデータ
        var params = {'news_id' : news_id, 'action_news_post_clap' : true};

        // 成功
        var processResponse = function(response)
        {
            if (!response.status) {
                alert(response.message);
                return false;
            }

//            alert('投票が完了しました。');
            location.reload();
            return false;
        };

        // エラー処理
        var notifyFailure = function(xml, status, e)
        {
//            alert('投票できませんでした。');
            return false;
        };

        $.ajax({
            'type'    : 'POST',
            'url'     : this.href,
            'dataType': 'json',
            'data'    : params,
            'success' : processResponse,
            'error'   : notifyFailure
        });

        return false;
    });

});

