2013-03-07 211 views
0

我有一些問題需要在IE 8中使用jQuery的get調用得到響應。在IE 9中(我認爲它也是IE 7)以及其他瀏覽器可以正常工作。在這裏我的代碼:IE 8 jQuery無法正常工作

$(document).ready(function() { 
    //Hide the Animation 
    $('#wait_generator').hide(); 
    //If an element is being selected, run the function 
    $('#generator').change(function(){ 
     //Display the animation 
     $('#wait_generator').show(); 
     //GET - Request at get_process.php 
     //get_process simply returns a new dropdown window 
     $('#result_generator').hide(); //Hide results at first 
     $.get("get_process.php", { 
      //Variable 'func' set to generator 
      func: "generator", 
      //Variable selected 
      selected: $('#generator').val() 
     }, 
     //GET - Response from PHP 
     function(response){ 
      $('#result_generator').fadeOut(); 
      setTimeout("finishAjax_generator('result_generator', '"+escape(response)+"')", 400); 
     })//End of GET Request; 
     return false; 
    }); 
}); 

//Displays the result 
function finishAjax_generator(id, response) { 
    $('#wait_generator').hide(); 
    $('#result_software').hide(); 
    $('#'+id).html(unescape(response)); 
    $('#'+id).fadeIn(); 
} 

調試我發現,IE 8不會運行的JSON符號後的「功能」(或全GET)代碼。我嘗試了絕對的網址和其他jQuery版本,並更改​​.php文件和和... 請任何人,幫助我找到任何解決方案。

+0

不喜歡這種通過代碼來'setTimeout',使用'的setTimeout(函數(){菲尼...' – 2013-03-07 10:06:07

+0

你也可以。請加jsfiddle – supersaiyan 2013-03-07 10:06:08

回答

1

嘗試改變:

setTimeout("finishAjax_generator('result_generator', '"+escape(response)+"')", 400); 

setTimeout(function() { 
    finishAjax_generator('result_generator', escape(response)); 
}, 400); 
+0

謝謝,是個不錯的選擇! – x4k3p 2013-03-07 11:01:15

+0

但是我發現還有一個額外的問題,如果瀏覽器不在兼容模式下,效果很好,但是如果是在這種模式下,什麼都不起作用。系統它只是沒有幫助切換模式。有人可以幫忙嗎? – x4k3p 2013-03-07 11:03:13