lundi 25 juillet 2016

Making get request for same domain giving CORS error

This my ajax call

                var xhr = new XMLHttpRequest();
                xhr.open('GET', window.location.href, true);
                xhr.responseType = "arraybuffer";
                xhr.onload = function(event) {
                 alert(this.response);
                };

I really do not understand why this giving me the error

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://ift.tt/2a7xj3i. (Reason: CORS header 'Access-Control-Allow-Origin' missing)

CORS comes into picture only once we are making the calls to other domain. But here I am making the call to the same domain. You can witness that in url xhr.open('GET', window.location.href, true);

What I am missing here ?

enter image description here




Aucun commentaire:

Enregistrer un commentaire