Friday, September 28, 2018

Ajax | Provisional Headers are shown | Cookies are not sent with request

Problem:

When making ajax calls, if you see that your Ajax is not cross domain and you are getting following issues:
1. Provisional Headers are shown in browser request headers
2. Cookies are not sent with request

Solution: 

This may happen if server side you are dependent on cookie values. You need to set cache false in your Ajax call by sending following param:

cache: false

So your Ajax look like this:
$.ajax({
                    url : "/some/resource/path/server/side",
                    type : "GET",
                    async : false,
                    cache: false,
                    success : callback,
                    error: errorCallback
});

If your Ajax is cross domain then you need add this param in your Ajax:
xhrFields : {withCredentials : true}

No comments:

Post a Comment

CDN | Clearing Cloudflare cache

In order to clear Cloudflare cache automatically via code, follow below steps: 1. Develop Custom TransportHandler Develop a custom Trans...