AngularJS默认情况下,缓存JSONP [英] AngularJS is caching JSONP by default

查看:108
本文介绍了AngularJS默认情况下,缓存JSONP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来AngularJS,我正在写经的$ HTTP JSONP方法收到
有回调JSON数据的应用程序。缓存参数没有设置,但浏览器缓存数据。我该如何解决?

i'm new to AngularJS, and i'm writing an app that recives JSON data with callback via $http jsonp method. Caching parameter is not set, but browser caches data. How can i solve that?

$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;});

};

推荐答案

不知道到底是什么角度在做,但是这通常是通过附加一个时间戳到URL来完成。从更改原始网址:

Not sure exactly what angular's doing, but this is typically done by appending a timestamp to the url. Change your original URL from:

'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())

这篇关于AngularJS默认情况下,缓存JSONP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆