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

174
Visualizações
Is there any way to make JavaScript (client-side) variables viewable or retrievable outside client side? If so, how?

I'm new to web development. Recently I created a basic "chatbot" for a friend of mine to use, but I am having trouble trying to implement a method for me to save what they enter as input. I would like to view what they enter into the chatbot, but cannot because JavaScript is at client-side, whereas I need to pass the values over some server (I am guessing) so that I may view what type of inputs they enter into the chatbot.

I have looked into several solutions, but I have had no luck trying them. For example, although I have never worked with either of these before, I just recently attempted to use the following php:

$to = "some-email@gmail.com";

$subject = "New Chatbot Query";

$message = file_get_contents("php://input");

mail($to, $subject, $message);

and AJAX:

 function sendPHP(input, output){
    const jsonString = JSON.stringify(input, output);
    const xhr = new XMLHttpRequest();
    console.log(jsonString);
    xhr.open("POST", "receive.php");
    xhr.setRequestHeader("Content-Type", "application/json");
    xhr.send(jsonString);
  }

in order to attempt to get an email from upon every input submission. Upon testing in LiveServer, the following error is shown in console: "Failed to load resource: the server responded with a status of 405 (Method Not Allowed)"

I would like to achieve a simple method to be able to read the input they put in the site, however currently I am having lots of trouble understanding servers/data base or how any of this works. I've tried looking up tutorials on AJAX, php, and more but I feel like there should be a simple way I just do not know of.

It should be noted, in HTML, the input field is NOT under a form. Which may have proved useful as my site is currently hosted on Netlify. However, doing so would cause the webpage to refresh upon any entered user-input and render the chatbot useless.

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