Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!