jQuery.Load() 在 IE9 中无法正常工作
在我网站的主页上,jquery.load()
在 $(document).ready()
处运行,并请求类似以下内容的 URL:
“/ajax/ Listings.aspx?pageindex=0"
当此页面运行时,在 Page_Load()
中,ListView
绑定到 DataSet
,后者返回一些产品出现。如果没有项目,则 EmptyDataTemplate
显示类似以下内容:
“当前没有产品”
在我的系统中,应显示 1 个产品。在 FireFox 中,它会返回并正确显示在页面上。
但是,在 Internet Explorer 中,会显示 EmptyDataTemplate
。此外,如果在 IE9 浏览器中打开 URL(“/ajax/Listings.aspx?pageindex=0”)(作为新选项卡),则返回 1 个产品。
为什么使用 jQuery.Load()
时 IE9 不将任何项目绑定到 ListView
?
On the home page of my site, jquery.load()
is ran at $(document).ready()
, and requests a URL something like:
"/ajax/Listings.aspx?pageindex=0"
When this page is ran, in the Page_Load()
a ListView
is bound to a DataSet
which returns some products to appear. If there are no items, then the EmptyDataTemplate
displays something like:
"There are currently no products"
In my system, there is 1 product that should be displayed. In FireFox, this is returned and displayed on the page correctly.
However, in Internet Explorer the EmptyDataTemplate
is displayed. Furthermore, if the URL ("/ajax/Listings.aspx?pageindex=0") is opened up in the IE9 browser (as a fresh tab), then this returns 1 product.
Why does IE9 not bind any items to the ListView
when jQuery.Load()
is used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然将随机字符串附加到 URL 有效,但处理此问题的最佳方法是禁用缓存:
取自 此处
While appending random strings to the URL works, the best approach to handle this is to disable the cache:
Taken from here
发布此文章后不久,我回去尝试看看我是否可以自己解决这个问题,并相信我已经找到了解决方案!
因为我在单独的选项卡中打开了 ajax 页面,所以当我返回主页时,现在正在显示该页面。
因此,我相信这是缓存的,刷新缓存的唯一方法是在新选项卡中打开它。
因此,我在 URL 末尾添加了一个随机字符串,以确保它不会每次都缓存页面:
Shortly after posting this I went back to try and see if I can work it out myself, and believe I've found the solution!
Because I'd opened the ajax page in a seperate tab, when I went back to the home page, this was now being shown.
Therefore, I believe this is cached, and the only way to refresh the cache is to open it in a new tab.
So, I've added a random string to the end of the URL to ensure it doesn't cache the page each time: