验证码刷新问题

I've a quick contact form on every page of my site. For captcha code I'm using free php catcha code generation script in img tag. Quick contact form is a separate form which I included in other pages. I tried jQuery $.ajax() function to refresh the code. But it refreshes 2-3 times only then it stuck. I need to refresh the captcha code every time when form is submited. What could be the solution?

If I understand the problem correctly, you can add a random number as the parameter when calling the captcha script.

<img src="captcha.php?rnd=<?php echo md5(time() . uniqid()); ?>" alt="captcha" />

Just make sure it's random enough.