Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
xmlHttpRequest CORS from dev server

I have this get request to a server. This site is hosted on a dev server, but I want to point this get request to a production server.

var requestList = new XMLHttpRequest();  

requestList.onreadystatechange = function() {  
    if (requestList.readyState==4&&requestList.status==200) {  
        display(JSON.parse(requestList.responseText));  
    }  
};  
requestList.open('GET','<link/to/php/server>',true);  
requestList.withCredentials = true;  

I'm getting a cors error. But, I can run this request from something like PowerShell and it works with the following code:

$url = "<link/to/php/server>"
$wc = New-Object System.Net.WebClient
$wc.UseDefaultCredentials = $true
$response = $wc.DownloadString($url)
$df = ConvertFrom-Json $([String]::new($response))

The PowerShell code just uses windows credentials. Since the PowerShell code works, I know I should be able to query the production server. But how to do it with JavaScript XMLHttpRequest?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda