这是我的jQuery函数
start: function() {
var text;
if(($('#choose2').css('display')!='none')){
text=$( "#select option:selected" ).text();
$('#1').load(this.path+'\compile.php?file=' +text).show();
}else if(($('#choose3').css('display')!='none')){
text=$( "#select option:selected" ).text();
$('#1').load(this.path+'\execute.php?file=' +text).show();
}
}
这就是问题所在:compile.php
工作正常,结果将显示在 id=1
的 div 中,但是 execute.php
页面使用之前传递给 compile.php
的相同 GET var(如果我从选择框中选择其他文件也是如此)。如果我之前不使用 compile.php
,则 execute.php
不起作用。为了测试,我在 compile.php
中使用了:
echo 'This is the file to compile '.$_GET['file'];
在 execute.php
中:
echo 'This is the file to execute '.$_GET['file'];
但正如我所写,文件保持不变。有什么建议吗?
最佳答案
您应该添加一个客户端或服务器端检查以确保在任何文件的 execute.php 之前调用了 compile.php
您可以将其存储在 session 或 cookie 中,甚至可以在客户端进行跟踪。
关于php - 使用 jquery 传递的 GET 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29940584/