Are you using the suneido:// protocol or running through HttpServer ?
I think you would make an AJAX call. If you are using HttpServer and may have different browsers then you might want to use something like jQuery.ajax
If you are using suneido:// then you can do something like suneido://eval?MyFunc()
If you’re using HttpServer then you would add your function to HttpMap
Your function can then do a query and return the results as JSON or XML.
Is that what you are looking for, or am I misunderstanding?