1

I'm pretty new to using JavaScript to perform requests, however I want to get the HTML of a page from https://www.halowaypoint.com but keep getting an error response of "XMLHttpRequest cannot load https://www.halowaypoint.com/en-us/players/PLAYER/halo4. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'URL' is therefore not allowed access." (PLAYER has been substituted).

I've heard CORS being mentioned several times after looking around, but I don't have server side access and I'm not sure how to reflect this in the request. Is there a way around this?

This is the code I've used so far:

$.ajax({
    type: 'get',
    url: 'https://www.halowaypoint.com/en-us/players/PLAYER/halo4',
    dataType:'text',
    contentType: 'text/plain',
    xhrFields: {
            withCredentials: false
    },
    headers: {
    },
    success: function(data) {
            alert(data)
    },
    error: function() {
            alert('Error')
    }
});

Thanks!

T3CHNOCIDE
  • 43
  • 1
  • 4
  • The "Access-Control-Allow-Origin" header can only be added server-side, or the internet would be *very* insecure. You could write your own server code (on your own server) to download the page for you and call that instead. – Reinstate Monica Cellio Feb 13 '14 at 23:05
  • Thanks very much for the help! I feared it may have been client side. I'll ask the server host for permission. – T3CHNOCIDE Feb 15 '14 at 20:13

0 Answers0