Yes the code would go in the UI project of your custom feature. However, if it needs any web.config stuff you would have to add that into the mojoPortal web.config file. I'm pretty sure with .svc type web services you need to declare the endpoints in web.config.
With .asmx type web service you may also need a web.config setting to declare the scripthandlerfactory, for use with ms ajax it would also require settings in scriptmanager but I think those wouldn't be needed for use with jquery
However, a simpler approach that could be done without any web.config settings would be to implement it as a generic handler (.ashx) which doesn't require endpoints declared in web.config but your js does of course need to know the url to the .ashx file.
You can see some example code for .ashx in mojoPortal source code in the Web/Services folder, we have some for CKeditor templates and TinyMCE templates return json.
Hope that helps,