I have a weird issue regarding jquery Dialog. I am using Jquery dialog for showing jcaptcha image. I have a refresh button on dialog. On click of a link, this captcha dialog should open. My issue is, image refresh button on dialog box. This refresh button works perfectly fine in Google chrome. Refresh button and new image works n number of times in chrome, but in IE 11, my refresh button works only once. It doesn't response anything on second time. I checked DOM values of new rendered image.New image gives new value from server, but still dialog is showing old image. Here is some bit code I am using
I am using JSF h:commandLink to initialize and open the dialog
<h:commandLink id="linkClicked" onclick="return srchPartyNameCaptchaCheck(this)"></h:commandLink>
Below is my Dialog Box content
<h:panelGrid id="captchaGrid" columns="2" styleClass="captchaGridClass" style="display: none;">
<h:panelGrid columns="1">
<h:graphicImage id="captchaText" value="/captcha"></h:graphicImage>
</h:panelGrid>
<h:panelGrid styleClass="captchaGridClass" columns="1">
<h:commandButton id="imgCaptchaReload" image="/resources/images/captcha/captchaReload.gif" immediate="true" onclick="return reloadCaptchaPartyName()">
</h:commandButton>
</h:panelGrid>
<h:panelGrid columns="1">
<h:inputText id="captchaSubmitted" required="true" validatorMessage="Insert text as shown in image" value="#{civilCaseSearchBean.captchaSubmitted}"></h:inputText>
</h:panelGrid>
</h:panelGrid>
Below is my jquery dialog code in javascript
function srchPartyNameCaptchaCheck(e){
$("#searchByPartyNameForm\\:captchaGrid").dialog({
autoOpen : false,
height : 260,
width : 480,
modal : true,
buttons: {
Submit: function () {//some ajax code for captcha validation},
Close: function () {
$(this).dialog("destroy");
}
}
Now final pieace of code, which is bothering me. javascript function which reloads image on dialog box. This works perfectly fine on Chrome, but on IE works only once!
function reloadCaptchaPartyName() {
var d = new Date();
$.ajax({
type: "POST",
url: "../captcha",
//url: "../CaptchaValidationServlet",
async: false,
cache: false,
success: function() {
},
error: function() {
alert("error");
},
complete: function(e) {
$('#searchByPartyNameForm\\:captchaText').removeAttr("src");
$('#searchByPartyNameForm\\:captchaText').removeAttr("value");
$('#searchByPartyNameForm\\:captchaText').attr("src","../captcha");
$('#searchByPartyNameForm\\:captchaText').attr("value","../captcha"+d.getTime());
}
});
}
Only thing I could figure out is, my dialog reference is lost after initialization of it in IE. Due to compatible support of jquery UI, Chrome is working as expected. I am not sure what I am missing or doing wrong. Your help is well appreciated.
Thanks folks