如何将var添加到文本javascript中

我有这个代码

$.ajax({ url: 'http://localhost/record/FlashWavRecorder-master/jjj/r/', type: 'HEAD', error: function () { $('.sd').html(''); }, success: function () { bo = 'a'; $('.sd').html('done '); } }); 

我想在这部分代码中添加varible

 url:'http://localhost/record/FlashWavRecorder-master/jjj/r/+var', 

只需附加这样的变量:

 url:'http://localhost/record/FlashWavRecorder-master/jjj/r/'+var, 

边注:
不要尝试使用use var作为变量名。 这是不可能的,因为var是保留关键字。
(但我确定这只是为了说明这个例子)

只需定义一个变量,然后将其附加到字符串中。

 var someValue = "hello"; $.ajax({ url:'http://localhost/record/FlashWavRecorder-master/jjj/r/' + someValue, 

附加如下:

  var something = "test"; $.ajax({ url:'http://localhost/record/FlashWavRecorder-master/jjj/r/' + something, 

Javascript不会在字符串中扩展变量,您必须使用+运算符将它们连接起来。

尝试使用以下内容

 url:'http://localhost/record/FlashWavRecorder-master/jjj/r/' + variable ,