Load page inside a div with Ajax

1

Good afternoon!

I am trying to use Ajax to load a page inside a div that I have, but it is giving 403 error (Forbidden). In case I can not do this? Would I have to do it any other way?

NOTE: The page I want to load is zendesk.

$j.ajax({
        url: "https://livreeleve.zendesk.com/hc/pt-br",
        type: "POST",
        beforeSend: function(){
            $j('.main-container.col1-layout').html('Carregando...');
        },
        success: function(r){
            $j('.main-container.col1-layout').html(r);
        }
});
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.livreeleve.com.br' is therefore not allowed access.

My domain is www.livreeleve.com

In case, I can only do this by releasing htaccess access?

    
asked by anonymous 26.10.2017 / 18:54

1 answer

1

Yes, this is because of the CORS settings, which is a protection against requests from other domains to your site, forbidding them from displaying it in a iframe , for example, as a form of clickjacking prevention and other types of exploit.

In order to access your website through a request from another site, you will need to change your htaccess file by adding the following line (taking into consideration your site):

Header set Access-Control-Allow-Origin "http://www.livreeleve.com.br"

Take a look here if you need more info: CORS in Apache

    
26.10.2017 / 19:09