いくつかのローカルjsonファイルを使用していますが、読み込み速度に問題があります。私のサーバーはPythonで作成された小さなウェブサーバーであり、通常はJavaScriptコードを試すために使用します。私のスクリプトはFirefoxでのみ動作し、60000ミリ秒の遅延を設定する必要があります(またはfirebugを使用します)。スクリプトは次のとおりです。
function geisson()
{
var iabile = new XMLHttpRequest();
iabile.open("GET", "longanocard.json", true);
iabile.send(null);
PerdiTempo(60000);
var objectjson = {};
var arrayCards= []; //creazione dell'array che conterrà le cards
objectson = JSON.parse(iabile.responseText);
arrayCards = objectson.cards;
//alert(arrayCards[0].__guid__.toSource());
var qwerty = arrayCards[0].__guid__;
var mela = "http://www.airpim.com/png/public/card/" + qwerty + "?width=292";
document.location = mela;
//windows.location.href= mela;
}
PerdiTempoは、遅延に使用する関数です。
function PerdiTempo(ms)
{
ms += new Date().getTime();
while (new Date() < ms){}
}
longanocard.jsonファイルの読み込みを高速化するにはどうすればよいですか?遅延が他のブラウザで機能しないのはなぜですか?