jquery - ajax 请求在 kiosk 浏览器上缓存

标签 jquery asp.net-mvc-3

我有一个 mvc 3 razor 项目,在 PC 上运行得很好,但在 iPad 上有一个问题,我有一个文章列表和一个用于测试的添加按钮,然后我按添加按钮,它现在返回日期时间,然后我按添加的按钮是返回日期时间,然后我按第二次它返回相同的日期时间,我在 iPad 上的项目是从缓存中获取值我想,每个人都可以帮助我吗??? 这个jquery代码:

$(document).ready(function (){        
    $(".AddButton").live("click", function(){                
        var buttonId = $(this).attr("id");                
        var id = buttonId.substr(buttonId.indexOf("_"));
        $.ajax({                
            type:'POST',
            dataType:'json',                
            url: "@Url.Action("AddCommandArtikelJson","Home")",
            data: {id:$("#Id"+id).val(), id_priceOnPad: $(this).attr("name")},
            cache: false,
            success: function(result){            
                $("#commandsCount").text(result);
            }
        });

    });
});

这个 Controller 功能:

 [HttpPost]
    public JsonResult AddCommandArtikelJson(int id, int id_priceOnPad)
    {//my code
         return Json(DateTime.Now);
    }

最佳答案

这种情况下的一个常见技巧是在查询字符串中传递一个随机字符串,这会诱使浏览器认为请求不同,从而绕过缓存。

关于jquery - ajax 请求在 kiosk 浏览器上缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13006630/

相关文章:

asp.net-mvc - ASP.NET : This method cannot be called during the application's pre-start initialization stage

c# - Controller 在 mvc 4 中不工作

javascript - 将 div 内容加载到不同的 div 中

javascript - 如何将 ViewModel 属性传递给 ajax post 方法?

jQuery - 从所有 div 中删除类,除了我点击的那个

javascript - 嵌套每个循环导致问题

installation - 无法安装 ASP.NET MVC3 RTM?

c# - ASP.NET MVC 3 显示模板问题

javascript - jQuery 替换/删除没有 id 或标签的属性

javascript - 具有大 DOM 的移动设备上的 CSS translate3d 性能问题