Solved

I have a perplexing 'autoSave not defined' error...

Posted on 2010-11-26
3
345 Views
Last Modified: 2012-08-13
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.
<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>

Open in new window

0
Comment
Question by:brianmfalls
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Accepted Solution

by:
jmatix earned 500 total points
ID: 34219309
Change:

function autoSaveEvery(ms) {
      var timeout = setTimeout('autoSave()', ms);
}

To:

function autoSaveEvery(ms) {
      var timeout = setTimeout(autoSave, ms);
}

0
 
LVL 53

Expert Comment

by:Huseyin KAHRAMAN
ID: 34219372
this one works fine...
so try to remove

$(document).ready(function() {
..
}

wrapper...
<script>
function autoSave(){
  alert(1);
}
		
var timeout = setTimeout('autoSave()',1000);
</script>

Open in new window

0
 
LVL 1

Author Closing Comment

by:brianmfalls
ID: 34219428
Thanks jmatix, that did the trick.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question