ram1
ram1

Reputation: 6470

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 = 
    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?

Upvotes: 0

Views: 590

Answers (1)

Andrew
Andrew

Reputation: 13853

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"]
};

Upvotes: 1

Related Questions