php - 使用 jquery 传递的 GET 变量

标签 php jquery css

这是我的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/

相关文章:

javascript - AJAX POST 请求发送 JS 代码,而不是操作

php - 清理 WooCommerce 中的自定义结帐字段数据

html - 使用 CSS 居中菜单

CSS3 : Is it possible to pause OTHER elements' animations on hover of an element?

css - 高度 100% 和 "bottom"不能一起工作

php - 回显随机数组

PHP imap_open - 不适用于 SSL 和 novalidate-cert 参数

javascript - 我应该将哪个 'event' 与 iOS/Android 上的 <input/> 元素一起使用?

javascript - 如何通过程序(例如 HTML、JS、PHP)更改浏览器的 pdf 查看器?

jquery - 从 jQuery UI 日期选择器格式化