AJAX案例研究之google suggest(轉)

heying1229發表於2007-07-28

google suggest 比起gmail要好對付的多了,就一個頁面一個指令碼檔案,程式碼都一目瞭然,可惜用了google域名,在調的時候經常連線被斷掉,最後還是找了一個代理才調通了程式碼。可以在本地執行的google suggest

請在這個連線下載:http://www.blog.net/Files/emu/suggest.rar

其中的指令碼檔案ac.js已經做了一點整理,關鍵的qc函式crack了一下,使它可以找到伺服器:

functionqc(ac){

if(l&&l.readyState!=0){

l.abort()

}

l=();

if(l){

l.open("GET",");

l.onreadystatechange=function(){

if(l.readyState==4&&l.responseText){

if(l.responseText.charAt(0)=="
V--

}else{

eval(l.responseText)

}

}

};

l.send(null)

}

}

插個斷點就可以看到,比如我們在輸入框中輸入了“AJAX”,google suggest就向伺服器請求這樣一個資源:

而伺服器則返回:

sendRPCDone(frameElement,"ajax",newArray("ajax","ajaxamsterdam","
ajaxfc","ajaxontario","ajaxgrips","ajaxfootballclub","ajaxpubliclibrary",
"ajaxfootball","ajaxsoccer","ajaxpickeringtransit"),
newArray("3,840,000results","502,000results",
"710,000results","275,000results","8,860results",
"573,000results","40,500results","454,000results",
"437,000results","10,700results"),newArray(""));
[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10172717/viewspace-928712/,如需轉載,請註明出處,否則將追究法律責任。

相關文章