Front end file upload using ajax

I’ve looked at the cookbook " Uploading files from frontend" and was wondering how this approach can be done using an ajax post instead of a full page post. Maybe as a virtual page? Anyone have an example of doing this? I’m using htmx.org to do the form post and my response will just be simple html so I really don’t need a full template returned.

You can post to a content representation or a route.

Not your use case, but here you can see how content representation is used with Ajax call: