I'm just looking for an answer online, but I have not reached anyone. I play with google api translation and I have problem with JS. Actually my code is 100% normal except for one operation.
My problem is that the translation is not given at that time. After js sends the information to google, it does not wait for the transfer. Instead, he continues to read my code, so he does not stop to get a response. It processes the information that will be translated, and then a response will be received some time after. Therefore, since I want to do translations of translations, I made a sweet loop. Since I don’t know how to stop js, I made a page with a different input text field, and in my loop, when the data is received, they send the value of the text field, and this is where it becomes the problem. I want to enter my js function again when the text is changed. If js changes the value, it will return to my loop when I receive the translation. Simple and effective, but if I put in the input field:
onchange="myfunction()"
the loop is not working. But the strangest thing is that if I manually change the text, the function works as if onchange only works when a person changes the text, but does not change the js text. Is there a solution? Maybe some kind of dynamic listener or something like that?
source
share