Load page inside a div with Ajax

Asked

Viewed 110 times

1

Good afternoon!

I’m trying to use Ajax to load a page inside a div I have, but it’s giving error 403 (Forbidden). In case I can’t do it? There’s no way I could do it any other way?

NOTE: The page I want to load is from 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.br

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

1 answer

1


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

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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.