I would like to set up autocomplete on a text box using jquery autocomplete with data from an arcserver service. I'm wondering if this is possible and if so how i would implement it. I'm using the esri javascript api v3.3 and arcserver 10.1.


Essentially, you are just passing an array to the autocomplete widget. If the data is in a map or feature service, query for the data from the service. If you start with a table in your mxd/msd that contains the data, when you publish it, you will get a REST endpoint for the table to query for in the same way. Next, parse out the data and push onto an array and pass it to the autocomplete widget.

    //build query task
    var queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3");
    //create an array
    var aStateNames = [];

    //build query filter
    var query = new esri.tasks.Query();
    query.returnGeometry = false;
    query.outFields = ["STATE_NAME"];
    query.where = "OBJECTID > 0";
    queryTask.execute(query, function (results) {
        //parse results and add to autocomplete widget
        dojo.forEach(results.features, function(value, index){
    }, function (error) {
        alert("Error: " + error);
  • Excellent, that works exactly as i wanted. Thanks.
    – Zachary
    Mar 7 '13 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.