thikonom
thikonom

Reputation: 4267

Problem with url

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? 

Upvotes: 0

Views: 77

Answers (3)

Adam
Adam

Reputation: 44929

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

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

Upvotes: 0

brabster
brabster

Reputation: 43560

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

Upvotes: 1

Oded
Oded

Reputation: 498914

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.

Upvotes: 0

Related Questions