javascript - jquery加载定义变量

标签 javascript jquery

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

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

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

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

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

})

})
</script>

我想将加载目标更改为 $("#shows").load("'+str+'.php"); 但这行不通。

怎么了?

最佳答案

你可以这样做吗,str 周围不需要引号 ('str')。

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

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

关于javascript - jquery加载定义变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50385133/

相关文章:

javascript - 发送额外的 JSON 数据以及发送序列化表单数据的现有 AJAX 帖子

jquery - 使用 Jquery 验证时无法提交表单

javascript - AJAX精简技巧?

javascript - Dojo 使用 xhrGet 从服务器获取数据并存储在变量中

javascript - fileOpener2 有什么问题吗?

javascript - 使用 react-router-redux 访问参数

jquery - 我无法使用 jQuery 更改 CSS 属性

javascript - 使用溢出时 div 内容向上滚动 : auto in IE 10

javascript - 使用 JQuery 切换 div 后重新加载 CSS

c# - 来自 C# 的 javascript unicode 属性