网址问题

时间:2010-09-29 16:52:30

标签: javascript

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

如何在http字符串中传递x的值,以便获得

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

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

像这样:

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

您需要将x的值连接到URL字符串。

答案 2 :(得分:0)

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

您应该使用JavaScript's + operator来连接字符串。

相关问题