U
U
UNy2018-05-22 15:44:33
JavaScript
UNy, 2018-05-22 15:44:33

Get request to the server?

There is a request
xhr.open('GET', '/about?name=5&age=27', true);
How to pass your variables instead of numbers? Let's say I have a variable:
let a = document.getElementById("btn2");
How can I send it with a Get request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Zhivagin, 2018-05-22
@UNy

let a = document.getElementById("btn2");
xhr.open('GET', `/about?name=${a}&age=27`, true);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question