日期:2014-05-16  浏览次数:20661 次

jquery 刷新页面后,增加阅读次数
$(function () {
    gacCount(2360);
});

function gacCount() {
    var $ArticleID = arguments[0];
    $.ajax({
        url: '/Handler/count.ashx?act=1' + "&articleid=" + $ArticleID,      
//提交到一般处理程序请求数据 count.ashx向数据增加一次阅读数,并读出新的阅读数
        type: "GET",
       dataType: "json",//采用JSON数据格式 
        success: function (data) {
          //显示Json中的数据
            $("#yCount").append(data[0].hit);
          $("#xCount").append(data[0].comment);  
        }
    });
}

以上代码只在页面第一次加载时显示出了,刷新页面没有重新操作数据库,请问,如果我要刷新一次页面执行一次gacCount,如何操作

------解决方案--------------------
//添加参数cache:false

    $.ajax({
       cache:false,
        url: '/Handler/count.ashx?act=1' + "&articleid=" + $ArticleID,      
//提交到一般处理程序请求数据 count.ashx向数据增加一次阅读数,并读出新的阅读数
        type: "GET",
       dataType: "json",//采用JSON数据格式 
        success: function (data) {
          //显示Json中的数据
            $("#yCount").append(data[0].hit);
          $("#xCount").append(data[0].comment);  
        }
    });