Jquery ui autocomplete - multiple sources

前端 未结 4 1451
说谎
说谎 2021-01-16 08:24

For 1 source this is the correct code after the ajax call: url: \"links2.xml\",

I would like the source to be multiple xml files. How do I include the extra paths

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 09:14

    First of all, the docs say that "the Autocomplete plugin expects that string to point to a URL resource that will return JSON data." Note: JSON, not XML so you need to convert your xml to json in the following.

    The xml to json can be done on your server or on the client browsers. It will be faster to do it once on your server, if possible.

    To use multiple source files, you will need to first load the multiple files in your HTML/JS page. Then concatenate them together into a Javascript array, then provide the array to the autocomplete call.

    Something like:

    
    
    # later...
    $( ".selector" ).autocomplete({source: myproject_choices });
    

提交回复
热议问题