No 'Access-Control-Allow-Origin' header is present on the requested Resource

Asked

Viewed 8,441 times

3

I am trying to do a biometric authentication on a remote machine using Xmlhttprequest. But it is returning the following message:

Xmlhttprequest cannot load http://177.55.99.146:8080/Autenticacao/autentica? file=[Object%20File]. No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://www.yaratecnologia.com.br' is therefore not allowed access

The code goes below. Does anyone know where the bug is? What should I do ?:

   <?php
       header('Access-Control-Allow-Origin', 'http://177.55.99.146:8080');
    ?>

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript">  
    function autenticarbiometria() { 
       var fileInput = document.getElementById('fileInput');
       var file = fileInput.files[0];
       var reader = new FileReader();
       var campo = "";
       var status = "f";;

       if (file.size != 400) {
          alert("ATENÇÃO --> O arquivo selecionado NÃO está em um formato Biométrico válido!");
          return false;
       }

       if (!confirm("CONFIRMA AUTENTICAÇÃO BIOMÉTRICA NA BASE DE DADOS?")) {
          return false;
       }

       if(window.XMLHttpRequest) {
          req = new XMLHttpRequest();
          }
       else if(window.ActiveXObject) {
          req = new ActiveXObject("Microsoft.XMLHTTP");
          }

       // Arquivo PHP juntamente com o valor digitado no campo (metodo GET)
       var url = "http://177.55.99.146:8080/autenticacao/autentica?arquivo="+file;

       // Chamada do metodo open para processar a requisicao

       req.open("GET",url,true);
       req.send(null); 

       // Quando o objeto recebe o retorno, chamamos a seguinte funcao
       req.onreadystatechange = function() {
         alert("Retorno do readyState == " + req.readyState + " readyStatus == " + req.status);
         if(req.readyState == 4 && req.status == 200) {
             // Resposta retornada pelo busca.php
             var resposta = req.responseText;
             alert("ATENÇÃO --> RETORNO AUTENTICACAO = " + resposta);
          }  
        }
  }
</script>

1 answer

-1

Browser other questions tagged

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