网址:http://www.never-online.net/code/neverModules/autocomplete/
网址:http://www.never-online.net/code/neverModules/autocomplete/sugguest.html
-----------------------------------------------------
我看他的源码,他的关键字内容为 //<![CDATA[
completeDataSource = [
{
'text':'never-online',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'google earth',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'ajax',
'content':'BlueDestiny[a]126.com'
},
{
'text':'中国',
'content':'BlueDestiny[a]126.com'
},
{
'text':'中华人民共和国',
'content':'BlueDestiny[a]126.com'
},
{
'text':'blueDestiny',
'content':'BlueDestiny[a]126.com'
},
{
'text':'never-online',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'google earth',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'ajax',
'content':'BlueDestiny[a]126.com'
},
{
'text':'blueDestiny',
'content':'BlueDestiny[a]126.com'
},
{
'text':'never-online',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'google earth',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'ajax',
'content':'BlueDestiny[a]126.com'
},
{
'text':'blueDestiny',
'content':'BlueDestiny[a]126.com'
}
];
那现在我要动态的取这个内容要怎么办呢
比如我输入 “鞋”
就会在我的数据库里面的
select top 10 鞋,数量 from 产品 order by 数量 desc
取得这些数据来做为他的completeDataSource谢谢
网址:http://www.never-online.net/code/neverModules/autocomplete/sugguest.html
-----------------------------------------------------
我看他的源码,他的关键字内容为 //<![CDATA[
completeDataSource = [
{
'text':'never-online',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'google earth',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'ajax',
'content':'BlueDestiny[a]126.com'
},
{
'text':'中国',
'content':'BlueDestiny[a]126.com'
},
{
'text':'中华人民共和国',
'content':'BlueDestiny[a]126.com'
},
{
'text':'blueDestiny',
'content':'BlueDestiny[a]126.com'
},
{
'text':'never-online',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'google earth',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'ajax',
'content':'BlueDestiny[a]126.com'
},
{
'text':'blueDestiny',
'content':'BlueDestiny[a]126.com'
},
{
'text':'never-online',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'google earth',
'content':'BlueDestiny[a]126.com',
'hints':'http://www.never-online.net'
},
{
'text':'ajax',
'content':'BlueDestiny[a]126.com'
},
{
'text':'blueDestiny',
'content':'BlueDestiny[a]126.com'
}
];
那现在我要动态的取这个内容要怎么办呢
比如我输入 “鞋”
就会在我的数据库里面的
select top 10 鞋,数量 from 产品 order by 数量 desc
取得这些数据来做为他的completeDataSource谢谢
xmlhttp.open("POST","GetDate.aspx",true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send(null);
xmlhttp.onreadystatechange=function()
{
if ( xmlhttp.readyState==4 || xmlhttp.readyState=='complete' )
{
alert("B:"+xmlhttp.responseText);
completeDataSource = xmlhttp.responseText;
}
}取出来的xmlhttp.responseText
如何来给completeDataSource 赋值谢谢
但是我用XMLHTTP取回来的是“字符”
所以出错要怎么改
xmlhttp.responseText就返回个字符串(加分隔符)
JS再split成数组给completeDataSource 赋值
---
通过eval() 函数可以将JSON字符串转化为对象。
var myObject = eval('(' + myJSONtext + ')'); eval 函数非常快,但是它可以编译任何 javascirpt 代码,这样的话就可能产生安全的问题。eval 的使用是基于传入的代码参数是可靠的假设的,有一些情况下,可能客户端是不可信任的。如果基于安全的考虑的话,最好是使用一个 JSON 解析器。 一个 JSON 解析器将只接受 JSON 文本。所以是更安全的。
var myObject = JSON.parse(myJSONtext, filter);
http://hi.baidu.com/chenwei6111/blog/item/2f8d9dc4549f51ad8326ac10.html