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

208
Visualizações
XMLHttpRequest.open() and .send() does not work

When I call this small piece of code in the Firefox browser console it works just fine. Sending a get request as it is supposed to.

{
  var http = new XMLHttpRequest();
  http.open("GET", "http://localhost:3456/?" + "q=test", true);
  http.send(null);
}

But as soon as I put the code into my Firefox content script - "permissions": ["*://localhost:3456/*","webRequest"] are set in the manifest.json, it refuses to send that request.

sendLocalPostRequest("q=test");

function sendLocalPostRequest(params) {
  var http = new XMLHttpRequest();
  const aURL = "http://localhost:3456/?" + params;
  http.open("GET", aURL, true);
  http.send(null);
}

I have the feeling that something is blocking the web request, but I can't figure out what it is. I already checked if one of the code lines throws an error message, but there aren't any... Any ideas on what could be the problem here?


UPDATE: I just added a few new permissions and one or the other seems to have solved my problem. Here they are "tabs","*://*/*",

about 4 years ago · Juan Pablo Isaza
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