I need to translate the text in a textarea. when I press the space key, an ajax request is made with the text in that field & then replaced by the response text.
But It would be better if I could just make an ajax request with the single word just before that space & then replace only that word by the response word. This way I could translate word by word & that’s exactly what I need.
Any ideas? Please share if you have any.
Function getLast returns the last word in the textarea
If the spacebar is pressed (keyCode 32), then call the getLast function on the value of the textarea. Then make an AJAX call passing the last word as a variable.
I feel like your best bet would be to translate the entire textarea word by word at the end, however.