52,797
社区成员
发帖
与我相关
我的任务
分享
//ajax部分
google.xhr = function() {
var a = null;
try {
a = new XMLHttpRequest
} catch(d) {}
return a
};
function r(a) {
return function() {
if (g[a.c].h) a.I++<3 && t(a);
else {
if (a.e.k) t(a);
else {
var b = google.xhr();
if (b) {
b.open("GET", a.q + a.l + "&zx=" + google.time());
a.t = 0;
b.onreadystatechange = function() {
if (b.readyState == 4) {
var c = 0;
if (b.status == 200) try {
eval(b.responseText);
c = 1
} catch(e) {}
if (!c && !a.C) {
g[a.c].h = 0;
a.C = 1;
a.q += "&cad=retry";
a.a.onmousedown()
} else {
a.u && u(a);
a.t = 0
}
}
};
a.t = 1;
b.send(null)
}
}
g[a.c].h = a.I = 1
}
}
}
<HTML>
<HEAD>
</HEAD>
<BODY>
<input id=txt1 type=text>
<div id=msg></div>
</BODY>
<script src="jquery.js" language="javascript"></script>
<script language="javascript">
var url ="http://www.google.cn/complete/search?hl=zh-CN&xhr=t&cp=";
function rend(xml){
$("#msg").html(xml[1][0].join());
}
var G = true;
$("#txt1").keyup(
function()
{
if(G)
{
G = false;
$.get(url,{q:this.value},function(xml){
$("#msg").html($.map(xml[1], function(n){return n[0]}).join("<br>"));
G = true;
});
}
}
);
</script>
</HTML>