desirepath41 / visualCaptcha-PHP

visualCaptcha for PHP
MIT License
101 stars 29 forks source link

there's no answer. #24

Closed zhangjian8652 closed 7 years ago

zhangjian8652 commented 7 years ago

If i click the refresh button too fast , There will be no answer image here. Can u help me to fixed it or tell me how to handdle it if i have something wrong.

BrunoBernardino commented 7 years ago

Hi @zhangjian8652 thank you for reporting this.

I've never experienced anything similar, are the requests to the backend failing? Is there a URL I can take a look at for this?

Thanks!

zhangjian8652 commented 7 years ago

image it looks like this image.

zhangjian8652 commented 7 years ago

I think it may be caused by the async of ajax.

zhangjian8652 commented 7 years ago

when images in session have been changed.

zhangjian8652 commented 7 years ago

image

BrunoBernardino commented 7 years ago

I understand, and without seeing how it's being called, I can't spot where the issue is, because if there's only 1 request to start the session, it should work fine. Can you show me where and how the code is working?

zhangjian8652 commented 7 years ago

That's right.
I click the refresh button twice very fast, first time is considered as A, second time is considered as B. A get the verify json data in session ,and then B get the json data , too. json data of B is the latest. after the two actions , js start to render the html document. There's a posibility that B is run before A, A render the document override B.after this action, browser start to load images in the session. So the tip message is A, but images in the session is B. This caused there's no answer.

BrunoBernardino commented 7 years ago

Thanks for the explanation.

It seems to me, from what you're saying, that the first request to the new images might be taking longer than the second one sometimes, making it so that the images you're seeing are for the first refresh and not the second.

There are a few ways to make that possible to prevent, but I honestly think it's an overkill for the goal here.

You could prevent any requests from happening while there are still unfinished requests, or simply make them synchronous. Whatever suits you better there.

Does that make sense? Do you need any help with how you might do that? If so, what front-end version are you using? jQuery?

zhangjian8652 commented 7 years ago

yes, i used jQuery. I understand what you said. Thanks for your help.

BrunoBernardino commented 7 years ago

Alright. I'll close this issue now and you can feel free to still ask questions here and even post your solution. Thanks!