开发者

YUI autocomplete url local datasource

I have an array that resides on the same domain as my html and I want to use the array as the source for an autocomplete textbox. Contents of myarr.json (1 MB):

["Aaronsburg, PA", "Abanda, AL", "Abbeville, AL", "Abbeville, GA" ... ]

I am using YUI2: AutoComplete and it works if I embed (a portion of) the array like this:

var myDataSource = 
开发者_如何学Python    new YAHOO.util.LocalDataSource(["Aaronsburg, PA", "Abanda, AL"]);

but my array is huge so I must link to it. When I do that:

var myDataSource = 
    new YAHOO.util.LocalDataSource("http://mydomain.com/myarr.json");

the console responds: GET http://mydomain.com/myarr.json/search/aarons/other/data 404 (Not Found)

How do I turn my array into json that can respond to the /search component of that GET statement?


If you want to "link" to it, you should just use the Remote Datasource.

The Examples go through how to Customize your datasource parsing.

YUI has very extensive documentation on all of this.

[Edit]

In response to your comment, see the Datasource Docs

Mainly under "Simple JavaScript Array",

myDataSource.responseSchema = {
    fields: ["name"]
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜