It's quite simple to do, but never risk free.
The easiest way is to get an addon that shows the ms on your current cast in real time.
That way you can better time it, but if the server has any weird hiccup of any kind during your attempt, you're fucked.
Stretch your cast bar to fill out as much of the screen as possible.
>Open bags
>click enchant
>open trade
>start enchanting the item
>put item inside the trade window
>other party instantly accepts
>person doing the enchant times their accept
Cast bar illustration [---------------------------------[--MS bar--]]
A = accept range indicator.
The idea is that you will accept somewhere before your cast enters the MS indicator of your cast bar, because that's when the lag tolerance kicks in and your cast will go off no matter what.
You want to time it late, but not too late. Sometimes it really depends on the server. My advice would be to play it relatively safe the first few tries, then work your way up.
First few attempts might look like this:
Cast Bar: [----------------------AAA--------[--MS bar--]]
Then if it doesn't work, you start accepting a bit later. At some point you will be successful.
Later attempts might look like:
Cast Bar: [----------------------------AAA--[--MS bar--]]
Good luck.