gpt4 book ai didi

javascript - AngularJS 默认缓存 JSONP

转载 作者:行者123 更新时间:2023-11-30 18:05:20 27 4
gpt4 key购买 nike

我是 AngularJS 的新手,我正在编写一个应用程序,通过 $http jsonp 方法通过回调接收 JSON 数据。未设置缓存参数,但浏览器缓存数据。我该如何解决?

$scope.fetch=function () {
$http({method: 'JSONP', url: 'http://angularjs.org/greet.php?callback=JSON_CALLBACK&name=Super%20Hero'})
.success(function(data) {
$scope.current = data.salutation.toLowerCase();
console.log($scope.current);
$scope.dim=$scope.current; doIt();}).error(function(data) {
$scope.current = data.salutation.toLowerCase() || "Request failed"; $scope.dim=$scope.current;});

};

最佳答案

不确定 angular 在做什么,但这通常是通过在 url 上附加时间戳来完成的。更改您的原始网址:

'http://angularjs.org/greet.php?callback=JSON_CALLBACK&name=Super%20Hero'

收件人:

'http://angularjs.org/greet.php?callback=JSON_CALLBACK&name=Super%20Hero&_=' + (new Date().getTime())

关于javascript - AngularJS 默认缓存 JSONP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15956768/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com