如何将var添加到文本javascript
我有这个密码如何将var添加到文本javascript,javascript,jquery,Javascript,Jquery,我有这个密码 $.ajax({ url: 'http://localhost/record/FlashWavRecorder-master/jjj/r/', type: 'HEAD', error: function () { $('.sd').html('<img src="5-0.gif" />'); }, success: function () { bo = 'a'; $('.sd').html('<
$.ajax({
url: 'http://localhost/record/FlashWavRecorder-master/jjj/r/',
type: 'HEAD',
error: function () {
$('.sd').html('<img src="5-0.gif" />');
},
success: function () {
bo = 'a';
$('.sd').html('<span style="color:#99CC00; font-weight:bold;">done</span> ');
}
});
只需像这样附加变量:
url:'http://localhost/record/FlashWavRecorder-master/jjj/r/'+var,
旁注:不要试图使用
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 ,
您的意思是要为ajax请求添加一些参数吗?按照undefined所说的去做,注意,“var”是保留字:)
url:'http://localhost/record/FlashWavRecorder-master/jjj/r/' + variable ,