Javascript 如何在IE中修复我的jQuery代码??在Firefox中工作

Javascript 如何在IE中修复我的jQuery代码??在Firefox中工作,javascript,jquery,internet-explorer,Javascript,Jquery,Internet Explorer,我正在使用jQuery显示/隐藏一个div容器(#pluginoptionscocontainer),并在其中加载一个页面(./plugin_options.php),其中包含发送的所需POST变量 发送的POST数据基于选择列表(#pluginDD)的值和点击按钮(#pluginOptionsBtn) 它在Firefox中运行良好,但在IE中不起作用。。“$”(“#pluginoptionscocontainer”).load()请求在IE中似乎从未完成-我永远只看到加载消息 bind()、e

我正在使用jQuery显示/隐藏一个div容器(#pluginoptionscocontainer),并在其中加载一个页面(./plugin_options.php),其中包含发送的所需POST变量

发送的POST数据基于选择列表(#pluginDD)的值和点击按钮(#pluginOptionsBtn)

它在Firefox中运行良好,但在IE中不起作用。。“$”(“#pluginoptionscocontainer”).load()请求在IE中似乎从未完成-我永远只看到加载消息

bind()、empty()和append()在IE中似乎都能正常工作。。但不加载()

这是我的密码:

// 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
//等待加载DOM
$(文档).ready(函数(){
//隐藏插件选项
$('#pluginoptionscocontainer').hide();
//这是对IE的攻击
如果($.browser.msie){
$(“#pluginDD”)。单击(函数(){
这个。blur();
这是focus();
});
}
//设置主功能
$(函数(){
//按钮显示隐藏插件选项页(及其容器)
$(“#pluginOptionsBtn”)。单击(函数(){
//显示插件选项页面的容器
$('pluginoptionscocontainer').empty().append('Loading…');
$(“#pluginoptionscocontainer”).toggle();
});
//如果用户使用下拉列表或按钮更改选择,则设置加载消息
$(“#pluginDD,#pluginOptionsBtn”).bind('change',function(){
$('pluginoptionscocontainer').empty().append('Loading…');
});
//然后,当插件按钮或下拉列表或单击或更改插件时,当插件更改时,更新页面
$(“#pluginDD,#pluginOptionsBtn”).bind('change click',function(){
//在js中将表单字段设置为变量
var-pid=;
var-cid=;
var pDD=$(“#pluginDD”).val();
//添加post变量(必须使用JSON)以发送到js变量“dataString”中
var dataString={plugin_options:true,pageid:pid,contentid:cid,pluginDD:pDD};
//在容器中包含plugin选项页面,所需的值已经添加到查询字符串中
$(“#pluginoptionscocontainer”).load(“/admin/inc/edit/content/plugin_options.php#pluginTop”,dataString);
//添加此选项可停止页面刷新
返回false;
});//结束提交函数
});//结束主函数
}); // 关于DOM负载

任何帮助都将不胜感激!我讨厌你

IE有时会缓存响应。您可以通过查看IE向服务器发出的请求进行检查。是一种用于监视http请求的工具

如果您注意到您点击了submit并且没有看到任何http请求,IE正在缓存结果

如果是这种情况,您可以向url添加一个随机数来缓存它:

$("#pluginOptionsContainer").load("url.php?random=" + Math.random()*99999, dataString);

IE有时会缓存响应。您可以通过查看IE向服务器发出的请求进行检查。是一种用于监视http请求的工具

如果您注意到您点击了submit并且没有看到任何http请求,IE正在缓存结果

如果是这种情况,您可以向url添加一个随机数来缓存它:

$("#pluginOptionsContainer").load("url.php?random=" + Math.random()*99999, dataString);

当涉及到重复的元素ID时,IE有时比FF更挑剔。
检查您使用的每个ID是否只使用了一次,并且在ajax调用期间没有重新创建。

IE有时在重复元素ID时比FF更挑剔。
检查您使用的每个ID是否只使用了一次,并且在ajax调用期间没有重新创建。

如果存在缓存问题,请尝试在jquery的ajax设置中设置cache=false

 $.ajaxSetup ({
        cache: false,
    });

如果存在缓存问题,那么请尝试在jquery的ajax设置中设置cache=false

 $.ajaxSetup ({
        cache: false,
    });

我几乎所有的jQuery帖子都必须这样做,IE这样做很烦人。@Tom Anderson:IE不缓存帖子请求的响应,只缓存GET。现在它可以工作了。。。我以前尝试过这个方法,使用了一种稍微不同的方法来计算随机数,但没有成功。。但他的那个是!非常感谢!!该死的你!我想我应该澄清一下,我的意思是发回服务器以获取信息,而不是发布帖子。我几乎所有的jQuery帖子都必须这样做,IE这样做很烦人。@Tom Anderson:IE不缓存帖子请求的响应,只缓存GET。现在它可以工作了。。。我以前尝试过这个方法,使用了一种稍微不同的方法来计算随机数,但没有成功。。但他的那个是!非常感谢!!该死的你!我想我应该澄清一下,我的意思是发回服务器以获取信息,而不是发帖。是的,我不久前注意到,这真是一件痛苦的事!是的,我注意到不久前,这是一个真正的痛苦的屁股!我这样做了,没有效果。。。但jrallison提供了有效的解决方案。。不管怎样,谢谢你。我这样做了,没有效果。。。但jrallison提供了有效的解决方案。。无论如何,谢谢你。