[英]what is the fastest way to get server time in JavaScript from a web browser?
[英]Fastest way to get data from server up to Javascript
因此,我正在開發的程序使用戶可以查看各種數據的不同Javascript實現的圖形表示(使用WebGL,JIT等)。 服務器端是用python編寫的,並在genshi + Buffet中使用cherrypy。
問題在於許多文件確實很大,並且實際數據到達Javascript所花費的時間開始成為問題。
到目前為止,該方法是使用服務器端公開的cherrypy方法:
@cherrypy.expose
@logged()
def read_server_file(self, coded_path):
"""
Retrieve file from Local storage, having a File System Path.
"""
try:
my_file = open(url2path(coded_path), "rb")
result = my_file.read()
my_file.close()
return result
except Exception, excep:
self.logger.error("Could not retrieve file from path:" +
str(coded_path))
self.logger.exception(excep)
這只是獲取磁盤上的實際文件,並從文件中返回數據。 在客戶端:
function getFile(fileName) {
oxmlhttp = null;
try {
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/plain");
} catch(e) {
try {
oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
return null;
}
}
if (!oxmlhttp) return null;
try {
oxmlhttp.open("GET", fileName, false);
oxmlhttp.send(null);
} catch(e) {
return null;
}
return oxmlhttp.responseText;
}
所以我的問題是,您是否知道任何更快/更有效的方法來獲取所需數據?
問候,博格丹
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.