How do I populate the select2 with default set of records and then based on the search text will do the ajax call?

Hi All,

I wanted to have a default set of records in select2 control while the DOM is ready. Then when the user puts characters on the search box based on the search text will do the Ajax call. Can you please help me provide some samples on the same?

Right now, Both of them are not happening at the same time. While the default set is getting populated the search with Ajax call is not happening and the control without default list is giving me the expected behavior but in that case we have to load the whole dataset.

Waiting for the comments. Thanks in advance.