brianmfalls
asked on
I have a perplexing 'autoSave not defined' error...
Console Error:
autoSave is not defined
[Break on this error] var timeout = setTimeout('autoSave()',ms );
I've tried several different 'fixes', but this error persists. The ajax call returns as it should. The error occurs post to the click function.
I believe the error is occurring at line 13.
autoSave is not defined
[Break on this error] var timeout = setTimeout('autoSave()',ms
I've tried several different 'fixes', but this error persists. The ajax call returns as it should. The error occurs post to the click function.
I believe the error is occurring at line 13.
<cfajaximport>
<script type="text/javascript">
$(document).ready(function() {
function autoSave(){
ColdFusion.Ajax.submitForm("finalRender", "/admin/emailBeta/act/act.save.email.cfm", callBack, callError);
autoSaveEvery(10000);
}
function autoSaveEvery(ms) {
var timeout = setTimeout('autoSave()',ms);
}
function callBack(res) {
if (res) {
document.getElementById('messageArea').innerHTML = 'Autosaved at ' + nowFormated();
}
}
function callError(res) {
if (res) {
document.getElementById('messageArea').innerHTML = 'Autosaved at ' + nowFormated();
}
}
function nowFormated(){
var now = new Date();
var ampm = "AM";
var hour = new Number(now.getHours());
if (hour > 12) {
ampm = "PM";
hour = hour - 12;
} else if (hour == 0) {
hour = 12;
}
var minutes = new Number(now.getMinutes());
if (minutes <= 9) {
minutes = "0" + minutes;
}
var seconds = new Number(now.getSeconds());
if (seconds <= 9) {
seconds = "0" + seconds;
}
return hour + ":" + minutes + ":" + seconds + " " + ampm;
}
$("#saveEmail").click(function () {
autoSave();
});
});
</script>
<div id="messageArea">Message Area</div>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks jmatix, that did the trick.
so try to remove
$(document).ready(function
..
}
wrapper...
Open in new window