2013-04-11 60 views
1

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

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

};

回答

2

不知道到底是什么角度在做,但是这通常是通过附加一个时间戳的URL来完成。

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

要:从改变你的原始URL

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

,这是我写的代码.. $ scope.fetch =函数(){$ HTTP({方法: 'JSONP' ,网址:“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;}); }; – davitp 2013-04-11 19:08:01

+0

小心把它放在你的问题,所以它可以正确格式化? – Travis 2013-04-11 19:09:39

+0

我改变了问题......仍然不明白为什么有一个缓存启用? – davitp 2013-04-11 19:16:30