我有一个带有多个选择框的 HTML/PHP 表单。在提交表单时,我调用一个 jquery 函数来创建一个带有来自选择框的变量和一些其他变量的查询字符串,并将这个查询字符串传递给 jQuery Tools Overlay 以在外部加载它。
覆盖正确加载并显示具有正确查询字符串的页面。当我关闭覆盖,更改一些选择框值并重新提交表单时,就会出现问题。外部页面仍然被加载,但查询字符串没有刷新,它与打开覆盖的第一个实例相同。
以下是我的jQuery代码:
$(function(){
$('#form').submit(function(){
. //code to get $str which contains the querystring Example $str="page='abc'&sub='xyz'"
.
$go='displaygroups.php?'+$str;
alert($go);//just to check if querystring is correct.
dispgrps($go);
return false;
});
function dispgrps($go){
$("#overlay").overlay({
// custom top position
top: 100,
// some mask tweaks suitable for facebox-looking dialogs
mask: {
color: '#d1eaf1',
loadSpeed: 10,
opacity: 0.9
},
// load it immediately after the construction
load: false,
onBeforeLoad: function() {
// grab wrapper element inside content
var wrap = this.getOverlay().find(".contentWrap");
// load the page specified in the trigger
wrap.load($go);
},
onClose:function(){
$('.contentWrap').html('Loading...');
}
});
$("#overlay").overlay().load();
}
});
如果我第一次从选择框中使用 page='1' 提交,那么即使将 select 的值更改为说 page='2' 并重新提交表单,外部页面 displaygroups.php 仍将页面反映为 1。
我只是在 displaygroups.php 上呼应值以进行测试:
if(isset($_GET['page'])) echo $_GET['page'];
覆盖css元素是
<div class="apple_overlay" id="overlay">
<!-- the external content is loaded inside this tag -->
<div class="contentWrap">Loading...</div>
</div>
请帮忙。谢谢你。
编辑:无法弄清楚,所以我更改了代码以使其成为链接而不是表单提交。现在可以了。