0
var x = 20;
xhr.open('GET','http://127.0.0.1:8000/insert/x);

How can i pass the value of x in the http string , so as to get

xhr.open('GET','http://127.0.0.1:8000/insert/20); as request? 

3 Answers 3

1

xhr.open('GET','http://127.0.0.1:8000/insert/' + x);

Sign up to request clarification or add additional context in comments.

Comments

0

Like this:

xhr.open('GET','http://127.0.0.1:8000/insert/' + x);

You need to concatenate the value of x to the URL string.

Comments

0
xhr.open('GET','http://127.0.0.1:8000/insert/' + x);

You should use JavaScript's + operator to concatenate the Strings.

Comments

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.