2013-03-15 26 views
2

我使用AJAX並同時執行一些javascripts/jquery。我正在使用.load()。現在我在IE7上遇到了問題,每個瀏覽器都能正常工作。不知何故,IE7不斷停止重複加載相同的內容。Ajax IE7不停止重裝問題

我一直在使用

$.ajaxSetup({ 
    cache: false 
}); 

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> 
<meta http-equiv="Pragma" content="no-cache" /> 
<meta http-equiv="Expires" content="0" /> 

無正在嘗試。

我真的不知道發生了什麼,找不到任何解決方案。

希望你們能幫助我。提前致謝。

我的AJAX代碼:

$('#ir_content').load(pageurl + ' #ir_inner_content'); 

而且由於其他文件是使用與後端語言手工編寫的JavaScript,所以我使用的onload的img標籤的1運行腳本:

<img src="/images/icon_loadingLarge.gif" width="32" height="32" alt="loading..." id="loading_indicator" style="display: none;" onload="var script_text = $('#webchart_js').html(); eval(script_text);" /> 

script_text:

<div id="webchart_js"> 
    (function($){ 
     var interactive_chart_config = { 
     zoom_historical_default: [% chart_config.chart.chart_interactive.zoom_historical_default %], 
     zoom_intraday_default: [% chart_config.chart.chart_interactive.zoom_intraday_default %], 
     quotes_delay: [% ir.var.Config.format.quotes_delay %], 
     news_on_chart: { 
      [% news_types = chart_config.chart.chart_interactive.news_on_chart.keys %] 
      [% FOREACH news_type = news_types %] 
      [% news_type %]: { 
       [% news_options = chart_config.chart.chart_interactive.news_on_chart.${news_type}.keys %] 
       [% FOREACH news_option = news_options %] 
       [% news_option %]: [% chart_config.chart.chart_interactive.news_on_chart.${news_type}.${news_option} ? 'true' : 'false' %][% IF news_option != news_options.last %],[% END %] 
       [% END %] 
      }[% IF news_type != news_types.last %],[% END %] 
      [% END %] 
     }, 
     modify_news: [ 
      [% FOREACH news = chart_config.chart.chart_interactive.modify_news.news %] 
      { 
       [% FOREACH key = news.keys %] 
       [% key %]: '[% news.${key} %]'[% IF key != news.keys.last %],[% END %] 
       [% END %] 
      }[% IF news != chart_config.chart.chart_interactive.modify_news.news.last %],[% END %] 
      [% END %] 
     ] 
     }; 

     $(document).ready(function(){ 
     $('#content_container').web_chart($.extend({}, { 
      theme : Highcharts.theme, 
      counter_code : "[%= stock_ids.first %]", 
      plot_on_load : true, 
      always_reload : true, 
       loading_indicator_id : 'loading_indicator', 
       chart_setting_id  : 'chart_setting', 
       counter_list_form_id : 'counter_list_form', 
       chart_container_id : 'chart_container', 
       css_class_for_flags : {'N' : 'news_tooltip', 'I' : 'insider_trades_tooltip', 'C' : 'corporate_actions_tooltip'} 
     }, interactive_chart_config)); 
     }); 
    })(jQuery); 

    </div> 
+0

你的ajax代碼是什麼?你如何觸發負載?給我們你的代碼。 – JoDev 2013-03-15 08:18:52

+0

嗨,JoDev,感謝您的幫助。我在上面插入了我的代碼,不知道是否足夠。 = x – Dr3am3rz 2013-03-15 08:27:44

+0

我很確定圖像的'onload'屬性不是必需的。我認爲將您的方法更改爲像「$ .ajax({});」這樣的Ajax調用可能是有用的。 'script_text'中可能有一段代碼觸發了一些問題。很抱歉,在你的情況下,我還需要'script_text'內容。 – JoDev 2013-03-15 08:45:43

回答

0

嘗試在ajax URL的末尾添加一個隨機字符串。這將停止IE緩存內容。像這樣:

$('#ir_content').load(pageurl + '?r=' + Math.Random() + '#ir_inner_content');

+0

嗨,Dean,謝謝你的幫助,但我已經試過了,沒用。 – Dr3am3rz 2013-03-15 09:22:52

+0

您是否嘗試過使用Fiddler來查看從服務器傳遞並返回的內容? – DAC84 2013-03-15 09:24:09

+0

對不起,問什麼是提琴手?因爲當我嘗試這些代碼時,它會返回整個html頁面,而不僅僅是#ir_inner_content div中的內容。 – Dr3am3rz 2013-03-15 09:28:29

0

什麼always_reload是什麼?通過將它傳遞給true,是否有可能重新加載IE7?

$(document).ready(function(){ 
     $('#content_container').web_chart($.extend({}, { 
      theme : Highcharts.theme, 
      counter_code : "[%= stock_ids.first %]", 
      plot_on_load : true, 
     /* 
      * HERE 
      */ 
      always_reload : true, 
       loading_indicator_id : 'loading_indicator', 
       chart_setting_id  : 'chart_setting', 
       counter_list_form_id : 'counter_list_form', 
       chart_container_id : 'chart_container', 
       css_class_for_flags : {'N' : 'news_tooltip', 'I' : 'insider_trades_tooltip', 'C' : 'corporate_actions_tooltip'} 
     }, interactive_chart_config)); 
     }); 
    })(jQuery); 
+0

嗨JoDev,我也不知道,因爲這不是我做的。但我試圖將其設置爲false,但它仍然無法正常工作。 – Dr3am3rz 2013-03-15 09:49:52

+0

顯然我已經嘗試把var script_text = $('#webchart_js')。HTML();的eval(script_text);進入.load(),整個事情不能被加載。所以我別無選擇,只能放入img tag onload。除了將onload加入img標籤之外,還有其他方法可以做嗎? – Dr3am3rz 2013-03-15 09:53:20

+0

'#ir_content'與''有關嗎? – JoDev 2013-03-15 10:07:28