Most of the CF developers face this issue
at least one time in their development life cycle. After made an investigation, we get to know , the
issue is because of careless javascript coding . To resolve this issue, we need
to place our javascript function within html <head></head> tag and
add <cfajaximport> tag on our cfm template.
Example:
Following test.cfm file will not work as we
expected, because we are not wrote the ‘init’ javascript function definition
with in html head tag.
test.cfm
<html>
<title>Test
Ajax OnLoad function</title>
<head></head>
<body>
<!---
Call javascript init(), by using ajaxOnLoad()--->
<cfset
ajaxOnLoad('init')>
<script
language="javascript">
init
= function()
{
alert('I
got a call through CF ajaxOnLoad function');
}
</script>
</body>
</html>
|
To resolve this, I’m going to place the
javascript function definition within html <head></head> tag and
add <cfajaximport> tag . Now try the modified test.cfm file
<html>
<title>Test
Ajax OnLoad function</title>
<head>
<script
language="javascript">
init
= function()
{
alert('I
got a call through CF ajaxOnLoad function');
}
</script>
</head>
<cfajaximport>
<body>
<!---
Call javascript init(), by using ajaxOnLoad()--->
<cfset
ajaxOnLoad('init')>
</body>
</html>
|
No comments:
Post a Comment