0

I've been looking for information on how I can send a client side variable to the server side using JavaScript. I'm a beginner and working on my first full stack web app and essentially i want to do something like this;

var userInput = $('#location-city').val();

This is taking in the value of a <input id="location-city"> in my html file on the client side.

I want to send this variable userInput to the server side where I use it with an API in the following manner:

baseUrl + userInput

This would add the userInput (which would be a city) to the baseUrl of my API and then return locations in a certain city. The reason why my API needs to stay on server side is because I'm using secret id's and tokens.

7
  • 4
    Did you use the search and had a look at any of the questions/answers in [javascript] pass variable to server? If not, please do that before asking a new question. Commented Nov 29, 2015 at 23:34
  • Perhaps this post too stackoverflow.com/questions/19014257/… Commented Nov 29, 2015 at 23:38
  • Could you give me more detail,sir? I thought you just need to get GET PARAMETER in your server side and use GET URL in your client side, but give me more info anyway. Commented Nov 29, 2015 at 23:56
  • You should look at the jquery api for http and Ajax they have functions that can handle this Commented Nov 29, 2015 at 23:58
  • Take a look at this question transfer-data-from-one-html-file-to-another it can solve your problem Commented Nov 30, 2015 at 10:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.