我使用jQuery来显示/隐藏一个div容器(#pluginOptionsContainer),并在其中加载一个页面(./pluginoptions.php)并发送所需的POST变量。
发送的POST数据基于选择列表的值(#pluginDD)和按钮的点击(#pluginOptionsBtn)……
它在Firefox中运行良好,但在IE中不起作用。在IE中,'$("#pluginOptionsContainer").load()‘请求似乎永远不会结束--我只会永远看到正在加载的消息...
bind()、empty()和append()在IE中似乎都工作得很好。而不是load()..
下面是我的代码:
// wait for the DOM to be loaded
$(document).ready(function() {
// hide the plugin options
$('#pluginOptionsContainer').hide();
// This is the hack for IE
if ($.browser.msie) {
$("#pluginDD").click(function() {
this.blur();
this.focus();
});
}
// set the main function
$(function() {
// the button shows hides the plugin options page (and its container)
$("#pluginOptionsBtn") .click(function() {
// show the container of the plugin options page
$('#pluginOptionsContainer').empty().append('<div style="text-align:center;width:99%;">Loading...</div>');
$('#pluginOptionsContainer').toggle();
});
// set the loading message if user changes selection with either the dropdown or button
$("#pluginDD,#pluginOptionsBtn").bind('change', function() {
$('#pluginOptionsContainer').empty().append('<div style="text-align:center;width:99%;">Loading...</div>');
});
// then update the page when the plugin is changed when EITHER the plugin button or dropdown or clicked or changed
$("#pluginDD,#pluginOptionsBtn").bind('change click', function() {
// set form fields as vars in js
var pid = <?=$pid;?>;
var cid = <?=$contentid;?>;
var pDD = $("#pluginDD").val();
// add post vars (must use JSON) to be sent into the js var 'dataString'
var dataString = {plugin_options: true, pageid: pid, contentid: cid, pluginDD: pDD };
// include the plugin option page inside the container, with the required values already added into the query string
$("#pluginOptionsContainer").load("/admin/inc/edit/content/plugin_options.php#pluginTop", dataString);
// add this to stop page refresh
return false;
}); // end submit function
}); // end main function
}); // on DOM load任何帮助都将不胜感激!我讨厌IE!
发布于 2010-03-20 15:40:56
IE有时会缓存响应。您可以通过观察IE向服务器发出的请求来进行检查。Fiddler2是一个很好的工具,用来监视http请求。
如果你注意到你点击了submit,但是没有看到任何http请求,IE会缓存结果。
如果是这样的话,你可以在url中添加一个随机数来缓存它:
$("#pluginOptionsContainer").load("url.php?random=" + Math.random()*99999, dataString);发布于 2010-03-20 15:45:42
当涉及到重复的元素ids时,IE有时比FF更挑剔。检查您使用的每个ID是否只使用一次,并且在ajax调用期间不会重新创建。
发布于 2010-03-20 16:13:56
如果缓存是问题所在,那么尝试在jquery的ajax设置中设置cache = false ...
$.ajaxSetup ({
cache: false,
});https://stackoverflow.com/questions/2482276
复制相似问题