Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
XMLHttpRequest Issue has been blocked by CORS policy:

I have this code in codepen and it works properly however if I installed this code on a wordpress site as a plugin, it says this error below.

Access to XMLHttpRequest at 'https://vative.us15.list-manage.com/subscribe/post' (redirected from 'http://vative.us15.list-manage.com/subscribe/post') from origin 'http://localhost:8888' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

My codepen is here.

https://codepen.io/gegejosper/pen/powzGQJ?editors=1011

$.ajax({
            type: "post",
            url: "https://vative.us15.list-manage.com/subscribe/post",
          
            dataType: "json",
          data: data_val,
        
            success: function(data) {
                $(".optin-form").hide();
                $(".optin-success").show();
            },
            //expected to be error in result.
            error: function(data){
              
              $(".optin-form").hide();
              $(".optin-success").show();
            }
        });

Is there a way to fix this issue? Please help.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Server (https://vative.us15.list-manage.com) has to allow the cross origin requests. As of now it's not allowing this. (Exact solution will depends on which language server is written)

I see the same issue in codeopen: index.html:1 Access to XMLHttpRequest at 'https://vative.us15.list-manage.com/subscribe/post' from origin 'https://cdpn.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

about 4 years ago · Juan Pablo Isaza Relatório

0

From the server-side (your VPS) add the following header:

Access-Control-Allow-Origin: *

Nodejs

res.writeHead(200, {'Access-Control-Allow-Origin': '*'});

PHP

header('Access-Control-Allow-Origin: *');

You can also white list certain domains as shown here :

Access-Control-Allow-Origin: https://codepen.io

For more info, check MDN

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda