Javascript 使用define变量加载jquery

Javascript 使用define变量加载jquery,javascript,jquery,Javascript,Jquery,我想设置jQuery加载目标。 下面的代码是工作代码 $(文档).ready(函数(){ $(“.first”)。单击(函数(){ var str=$(this.attr(“value”)/ $(“.sencond”).hide(); $(“#shows”).html(“等待…”); $(“#shows”).show(); $(“#shows”).load('load.php?str='+str); }) }) 你能这样做吗,str周围不需要引号('str') $("#shows").loa

我想设置jQuery加载目标。 下面的代码是工作代码


$(文档).ready(函数(){
$(“.first”)。单击(函数(){
var str=$(this.attr(“value”)/
$(“.sencond”).hide();
$(“#shows”).html(“等待…”);
$(“#shows”).show();
$(“#shows”).load('load.php?str='+str);
})
})

你能这样做吗,str周围不需要引号(
'str'

$("#shows").load( str+ ".php")
$(“#shows”).load(“+str+”.php”)有问题
它将生成字符串作为“strvalue”。php
而该页面将找不到。

以下是工作代码:

<script>
$(document).ready(function() {

$(".first").click(function(){
var str=$(this).attr("value"); 

$(".sencond").hide();  
$("#shows").html("wait ... ");
$("#shows").show();

$("#shows").load(str+'.php'); 

})

})
</script>

$(文档).ready(函数(){
$(“.first”)。单击(函数(){
var str=$(this.attr(“value”);
$(“.sencond”).hide();
$(“#shows”).html(“等待…”);
$(“#shows”).show();
$(“#shows”).load(str+'.php');
})
})
确保加载php页面应该在那里

使用js模板字符串

$("#shows").load(`${var}.php`)

请尝试解决方案
$(“#shows”).load(str+“.php”)
有效吗?