问题
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;});
};
回答1:
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'
To:
'http://angularjs.org/greet.php?callback=JSON_CALLBACK&name=Super%20Hero&_=' + (new Date().getTime())
来源:https://stackoverflow.com/questions/15956768/angularjs-is-caching-jsonp-by-default