Avatar of Newco
Newco
Flag for United States of America

asked on 

CF8 and Java Ajax login script

Hi all,

I picked up a script not long ago (forgot where or I would give credit) that uses a Coldfusion window and Javascript to log in to my site.  Everything works great - it replaces the content in a couple of DIVs and so forth.  What I would like to do is refresh the page just once on a successful log in.  I tried a window.location.reload() and it didn't seem to work.  Any suggestions?

Thanks!
<script>
function doLogin() {
	ColdFusion.Window.create('loginwindow','Login','login.cfm',{center:true,modal:true,height:180,width:300,resizeable:false});
	Coldfusion.Window.alignTo('parentDiv',0,0);
 
}
 
function handleResponse(s) {
	if(s == "good") {
		//first hide the window
		ColdFusion.Window.hide('loginwindow');
		//rewrite out login
		var loginspan = document.getElementById('loginstatus');
		var newcontent = "<a href='index.cfm?logout=1'>Logout</a>";
		var myaccountspan = document.getElementById('my_account');
		var myaccountnewcontent = '<div class="gallery">Welecome<cfif isDefined('session.auth.email')><cfoutput>, #session.auth.email#</cfoutput>.</cfif> You can visit your Account Page to update your information, manage your Favorites, and much more.</div>';
		loginspan.innerHTML = newcontent;
		myaccountspan.innerHTML = myaccountnewcontent;
	} else {
		alert('There was a problem with your login.  Please try again.');
	}
 
}
 
function handleLogin() {
	ColdFusion.Ajax.submitForm('loginform','processlogin.cfm',handleResponse);
}
 
 
</script>

Open in new window

JavaScriptColdFusion Language

Avatar of undefined
Last Comment
Newco

8/22/2022 - Mon