I have a class in folder ImageCaptcha
private string GetCaptchaText(int length)
{
var possibleCaptchaCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var result = "";
Random random = new Random();
for (int index = 0; index < length; index++)
{
result += possibleCaptchaCharacters[(int)Math.Ceiling(random.NextDouble() * possibleCaptchaCharacters.Length - 1)].ToString();
}
return result;
}
I also have image with property onclick on registration page
<button id="refresh"><img src="~/Images/captcha-refresh.png" height="22" width="29" alt="" onclick="reFreshCaptchaImage()"></button>
Can i get data from function GetCaptchaText which returns random number.. with ajax because i always get error when i use this script below?
function reFreshCaptchaImage() {
$.ajax({
type: 'GET',
url: "../CaptchaImage/test/Index",
success: function (msg) {
alert(msg);
},
error: function () {
alert("error");
}
});
}
I want to refresh that part without refreshing whole page