Here is my captcha.php script: (it creates an image)
// creating a image in this script and set its value on the session
Also I have a <img>
in the contact_us.php file for showing that captcha image:
<img src="http://localhost/captcha.php" class="captcha_pic" alt="Captcha">
Also I have an ajax code for submiting that form in the contact_us.js (this file is atteched to contact_us.php):
$("#f_contact_form").on("submit", function (e) {
e.preventDefault(e);
$.ajax({
url: $("#f_contact_form").attr("action"),
type: 'POST',
data: $("#f_contact_form").serialize(),
dataType : 'JSON',
success: function (contact) {
$(".contact_message").html(contact.message);
// here I need to reload that image url for changing the captcha image
}
});
});
It should be noted that when I change the url of that image using [inspect element] (in the static) and then I write the correct name, the image will be changed. for example I replace the current image url with src=".../captcha.ph"
and then I write the correct name src=".../captcha.php"
, then the page will be changed (exactly what I want).
Now there is any solution for reloading captcha image?