Ajax JSON Template
<! Doctype HTML public " -// W3C // dtd xhtml 1.0 transitional // en " " Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< HTML xmlns = " Http://www.w3.org/1999/xhtml " >
< Head >
< Meta HTTP - Equiv = " Content-Type " Content = " Text/html; charset = UTF-8 " />
< Title > Untitled document </ Title >
< Script SRC = " Jquery-1.4.4.min.js " Language = " Javascript " Type = " Text/JavaScript " >
</ Script >
< Script Type = " Text/JavaScript " >
Function load ()
{
Alert ( " Test " );
Hotsearch ( " Http://api.t.sina.com.cn/users/show/wangkangluo1.json? Source = 3153373932 " );
}
Function hotsearch (INDEX)
{
If (Window. XMLHttpRequest)
{ // Code for IE7 +, Firefox, chrome, opera, Safari
XMLHTTP = New XMLHttpRequest ();
// Sortname = encodeuri (sortname );
}
Else
{ // Code for IE6, ie5
XMLHTTP = New Activexobject ( " Microsoft. XMLHTTP " );
// Sortname = encodeuri (sortname );
}
// Q = encodeuri (type );
Gscriptobj = Document. createelement ( " Script " );
Gscriptobj. setattribute ( " Type " , " Text/JavaScript " );
Gscriptobj. setattribute ( " Charset " , " UTF-8 " );
// If (Index = 1)
// {
Gscriptobj. setattribute ( " SRC " , Index );
Headobj = Document. getelementsbytagname ( " Head " ). Item ( 0 );
Headobj. appendchild (gscriptobj );
}
Function json_back (JSON)
{
Alert (JSON );
}
</ Script >
</ Head >
< Body onload = " Load () " >
< Div Class = " Me " > Test </ Div >
</ Body >
</ Html >
finished