Macro that creates form for remote ajax query (how to implement)

We have successfully used [1] to create an XWiki page with a form. We have a slightly different use case: we would like to have a macro that yields a field (?) which queries one of our (remote) db servers via ajax for an entry in a long table (we already have code for the ajax/Django part). The table on our db server contains > 1000 entries (chemicals/lab equipment), each one has a unique identifier and that should remain in the XWiki page after selection - this is, of course, too long for any type of pulldown menu but might work with autocompletion (for this specific type of data). Is there an obvious way to implement this with XWiki? Thanks!

[1] How can I create a new page based on a form? (

We have found a good workaround (for now): we have used the remote server to create an XWiki page for each entry in the database and users can now insert a link to that page in their labbooks.