How do you disable cross origin restrictions to run on localhost?

Asked

Viewed 304 times

0

<!doctype html>
<html lang="pt-br">

<head>
    <meta charset="utf-8">
    <title>Teste - LOTECE</title>
</head>

<body>
    <div class="resultado"></div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $('.resultado').load('http://www.lotece.com.br/v2/ .dataResultado');
        });
    </script>
</body>

</html>

I have the above code, but the problem of not listing the results has to do with cross-origin. I’m a beginner in a lot of things and I don’t know how to solve this problem. At first it was supposed to be this, when accessed localhost/Test.html.

inserir a descrição da imagem aqui

I would appreciate it if you would help me solve this problem. [I don’t even know where to start, rs]

  • You are accessing your Teste.html from a local server or by uploading the file directly (file://.../Teste.html)? can post console error?

  • Is this domain lotece.com.br yours? It’s the one that needs to free the access, if it’s not in your control there’s no way.

  • If it is just to test ajax, you should start your Chrome with the argument: -disable-web-security . This will work just for you or whoever starts Chrome with it. If you are going to use different domains when the system is in production (multiple people using), you will have to release in the application hosted in lot.com.br

  • At first I only stopped the file [I opened on Chrome] @bfavaretto . Lotece.com.br is the domain I want to pull the results and an external website.

  • @Hugolima the intention was to make an application that showed the results. I don’t know how to do this on the server either. Users would access and see the results of lot.com.br.

  • As well pointed out by @bfavaretto, the CORS protection is on the server side. There’s nothing to do. One suggestion is to create a script in your application (php, Node...) that acts as a proxy. This would allow you to access this page with AJAX.

  • Srs @Hugolima mrlew bfavaretto then change my question and ask how to get the results of www.lotece.com.br/v2/ and list on a page ? In a simple way. Att

  • Ask another question @CRISLANIO. This one has already been answered.

  • You are not accessing a server on the localhost, but in batch.com.

Show 4 more comments

1 answer

0

That was the solution. But testing another day just doesn’t show anything else.

<!doctype html>

Cris - LOTECE

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){
        $('.resultado').load('https://crossorigin.me/http://www.lotece.com.br/v2/ .dataResultado');
    });
</script>

The result that was generated and the next day no longer found in the image.inserir a descrição da imagem aqui

Browser other questions tagged

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