Angular in Ajax request header configuration IE does not cache requests

Source: Internet
Author: User

Config ([' $locationProvider ', ' $urlRouterProvider ', ' $httpProvider ', function ($locationProvider, $urlRouterProvider    , $httpProvider) {$locationProvider. Hashprefix ('! ');    $urlRouterProvider. Otherwise ('/customization/funsetting ');    $httpProvider. defaults.headers.put[' content-type '] = ' application/x-www-form-urlencoded ';        $httpProvider. defaults.headers.post[' content-type '] = ' application/x-www-form-urlencoded '; Initialize get if not there if (! $httpProvider. Defaults.headers.get) {$httpProvider. defaults.headers.        get = {}; }//Answer edited to include suggestions from comments//Because previous version of code introduced brows er-related Errors//disable IE ajax request caching $httpProvider. defaults.headers.get[' If-modified-since '        = ' Mon, Jul 1997 05:00:00 GMT ';        Extra $httpProvider. defaults.headers.get[' cache-control '] = ' no-cache ';  $httpProvider. defaults.headers.get[' Pragma '] = ' no-cache ';  $httpProvider. Defaults.transformrequest = [function (data) {/** * the workhorse; Converts an object to X         www-form-urlencoded Serialization.            * @param {Object} obj * @return {String} */var param = function (obj) {var query = ';            var name, value, Fullsubname, SubName, Subvalue, innerobj, I;                for (name in obj) {value = Obj[name];  if (value instanceof Array) {for (i = 0; i < value.length; ++i) {Subvalue =                        Value[i];                        Fullsubname = name + ' [' + i + '] ';                        Innerobj = {};                        Innerobj[fullsubname] = Subvalue;                    Query + = param (innerobj) + ' & ';                        }} else if (value instanceof Object) {for (subname in value) {                        Subvalue = Value[subname]; Fullsubname = name + ' [' + SubName + '];                        Innerobj = {};                        Innerobj[fullsubname] = Subvalue;                    Query + = param (innerobj) + ' & '; }} else if (value!== undefined && value!== null) {query + = Encodeuricomponen                T (name) + ' = ' + encodeuricomponent (value) + ' & '; }} return query.length?        Query.substr (0, query.length-1): query;        }; return Angular.isobject (data) && String (data)!== ' [Object File] '?    Param (data): data; }];}]). Run ([' $rootScope ', ' $state ', ' $stateParams ', function ($rootScope, $state, $stateParams) {$rootScope. $state = $s        Tate    $rootScope. $stateParams = $stateParams; }]);

Angular in Ajax request header configuration IE does not cache requests

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.