2015-04-28 32 views
1

我不知道爲什麼XMLHttpRequest()在Firefox中不起作用。適用於Chrome和IE。 此代碼是關於更改我的網站的語言。XMLHttpRequest()在Firefox中不起作用。

<script type="text/javascript"> 
$(document).ready(function(){ 

$("#idioma_ingles").click(function(){ 
xmlhttp = new XMLHttpRequest(); 
xmlhttp.open("GET", "?idioma=2", true); 
xmlhttp.send(); 
    location.reload(); 

}); 

$("#idioma_espanol").click(function(){ 
xmlhttp = new XMLHttpRequest(); 
xmlhttp.open("GET", "?idioma=1", true); 
xmlhttp.send(); 
    location.reload(); 

    }); 

}); 

</script> 
+0

它可以是請求之前,你的頁面重載被髮送? – BobbyTables

回答

1

要麼做這樣的所以頁面得到重新加載請求完成後,或只是跳過AJAX和使用常規的鏈接

$.get("?idioma=1", function() { 
location.reload(); 
}); 
0

你重新加載頁面(使得該請求被取消)你叫send()之後。

您可以在致電reload()之前等待響應,但最好不要使用Ajax:沒有意義。只需使用到?idioma=whatever的定期鏈接。

相關問題