inverted_2000
asked on
AJAX on ColdFusion 5 Server
Hey Hey everyone,
Can CF5 run AJax? I've looked into JSMX and CFAJAX but they all use the "cffunction" tag heavily in their code...and CF5 will not run that tag.
The solution that I am trying to do is at http://69.84.175.243/test/default.cfm and is 90% JavaScript right now...and it's not working correctly. Before I began this project...everyone said to look to AJAX to accomplish this task...and it looked like it would, but since my CF5 server will not run the examples of Ajax that I have seen I turned to straight JavaScript to do it.
Not being a JavaScript Guru is my fault...but that's just how it is and I need AJAX to make up for my lacking JavaScript skills.
Thanks a lot,
inverted
Can CF5 run AJax? I've looked into JSMX and CFAJAX but they all use the "cffunction" tag heavily in their code...and CF5 will not run that tag.
The solution that I am trying to do is at http://69.84.175.243/test/default.cfm and is 90% JavaScript right now...and it's not working correctly. Before I began this project...everyone said to look to AJAX to accomplish this task...and it looked like it would, but since my CF5 server will not run the examples of Ajax that I have seen I turned to straight JavaScript to do it.
Not being a JavaScript Guru is my fault...but that's just how it is and I need AJAX to make up for my lacking JavaScript skills.
Thanks a lot,
inverted
ASKER
The how might I run something like CFAJax on CF5?
Here's the JSMX .cfc file that I would need to be recoded for CF5...can you do that?
<CFCOMPONENT output="No">
<cfsetting enablecfoutputonly="Yes" showdebugoutput="No">
<CFFUNCTION name="getList" access="remote" returntype="void">
<cfquery name="qList" datasource="northwind">
SELECT employeeId, LastName+', '+firstName AS name
FROM employees
ORDER BY lastname,firstname
</cfquery>
<cfset LIs = ''>
<cfloop query="qList">
<cfset LIs = LIs&"<li><a href='javascript:details_r equest(#em ployeeId#) ;'>#name#< /a></li>">
</cfloop>
<!--- return object --->
<cfwddx action="cfml2js" input="#LIs#" toplevelvariable="r">
</CFFUNCTION>
<CFFUNCTION name="getDetails" access="remote" returntype="void">
<CFARGUMENT name="eid" type="numeric" reqDetailsired="Yes" default="0">
<cfquery name="qDetails" datasource="northwind">
SELECT EmployeeId,Title,FirstName ,LastName, HireDate,c ity,region ,postalcod e,Notes
FROM employees
WHERE employeeId = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#val(arguments.eid) #">
<!--- security statement to ensure only correct user accesses --->
</cfquery>
<cfset xObj = structNew()>
<cfset xObj.EID = qDetails.EmployeeId>
<cfset xObj.title = qDetails.title>
<cfset xObj.firstName = qDetails.firstname>
<cfset xObj.lastName = qDetails.lastname>
<cfset xObj.hireDate = qDetails.hireDate>
<cfset xObj.city = qDetails.city>
<cfset xObj.state = qDetails.region>
<cfset xObj.zip = qDetails.postalcode>
<cfset xObj.notes = qDetails.notes>
<!--- return object --->
<cfwddx action="cfml2js" input="#xObj#" toplevelvariable="r">
</CFFUNCTION>
<CFFUNCTION name="putDetails" access="remote" returntype="void">
<cftry>
<cfquery datasource="northwind">
UPDATE employees
SET title = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.title#"> ,
firstName = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.firstnam e#">,
lastName= <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.lastname #">,
hireDate = <cfqueryparam cfsqltype="CF_SQL_DATE" value="#createODBCdate(arg uments.hir edate)#">,
notes = <cfqueryparam cfsqltype="CF_SQL_LONGVARC HAR" value="#arguments.notes#">
WHERE employeeId = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#val(arguments.eid) #">
<!--- security statement to ensure only correct user accesses --->
</cfquery>
<cfset result = val(arguments.eid)>
<cfcatch>
<cfset result = 0>
</cfcatch></cftry>
<!--- return object --->
<cfwddx action="cfml2js" input="#result#" toplevelvariable="r">
</CFFUNCTION>
<!--- Read the NOTES of the readme.txt file included with this sample app before adding this functionality to your LIVE Web Applications. --->
<CFFUNCTION name="getCityStateFromZip" access="remote" returntype="void">
<cfargument name="zip" type="string" required="Yes" default="00000">
<cfset result = structNew()>
<cfset result.city = "">
<cfset result.state = "">
<cfhttp method="GET" url="http://www.webservicex.net//uszip.asmx/GetInfoByZIP?USZip=#arguments.zip#"/>
<cftry>
<cfset addyObj = xmlParse(cfhttp.fileconten t)>
<cfset result.city = trim(addyObj.newDataset.ta ble.city.x mlText)>
<cfset result.state = trim(addyObj.newDataset.ta ble.state. xmlText)>
<cfcatch></cfcatch></cftry >
<cfwddx action="cfml2js" input="#result#" toplevelvariable="r">
</CFFUNCTION>
</CFCOMPONENT>
Here's the JSMX .cfc file that I would need to be recoded for CF5...can you do that?
<CFCOMPONENT output="No">
<cfsetting enablecfoutputonly="Yes" showdebugoutput="No">
<CFFUNCTION name="getList" access="remote" returntype="void">
<cfquery name="qList" datasource="northwind">
SELECT employeeId, LastName+', '+firstName AS name
FROM employees
ORDER BY lastname,firstname
</cfquery>
<cfset LIs = ''>
<cfloop query="qList">
<cfset LIs = LIs&"<li><a href='javascript:details_r
</cfloop>
<!--- return object --->
<cfwddx action="cfml2js" input="#LIs#" toplevelvariable="r">
</CFFUNCTION>
<CFFUNCTION name="getDetails" access="remote" returntype="void">
<CFARGUMENT name="eid" type="numeric" reqDetailsired="Yes" default="0">
<cfquery name="qDetails" datasource="northwind">
SELECT EmployeeId,Title,FirstName
FROM employees
WHERE employeeId = <cfqueryparam cfsqltype="CF_SQL_INTEGER"
<!--- security statement to ensure only correct user accesses --->
</cfquery>
<cfset xObj = structNew()>
<cfset xObj.EID = qDetails.EmployeeId>
<cfset xObj.title = qDetails.title>
<cfset xObj.firstName = qDetails.firstname>
<cfset xObj.lastName = qDetails.lastname>
<cfset xObj.hireDate = qDetails.hireDate>
<cfset xObj.city = qDetails.city>
<cfset xObj.state = qDetails.region>
<cfset xObj.zip = qDetails.postalcode>
<cfset xObj.notes = qDetails.notes>
<!--- return object --->
<cfwddx action="cfml2js" input="#xObj#" toplevelvariable="r">
</CFFUNCTION>
<CFFUNCTION name="putDetails" access="remote" returntype="void">
<cftry>
<cfquery datasource="northwind">
UPDATE employees
SET title = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
firstName = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
lastName= <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
hireDate = <cfqueryparam cfsqltype="CF_SQL_DATE" value="#createODBCdate(arg
notes = <cfqueryparam cfsqltype="CF_SQL_LONGVARC
WHERE employeeId = <cfqueryparam cfsqltype="CF_SQL_INTEGER"
<!--- security statement to ensure only correct user accesses --->
</cfquery>
<cfset result = val(arguments.eid)>
<cfcatch>
<cfset result = 0>
</cfcatch></cftry>
<!--- return object --->
<cfwddx action="cfml2js" input="#result#" toplevelvariable="r">
</CFFUNCTION>
<!--- Read the NOTES of the readme.txt file included with this sample app before adding this functionality to your LIVE Web Applications. --->
<CFFUNCTION name="getCityStateFromZip"
<cfargument name="zip" type="string" required="Yes" default="00000">
<cfset result = structNew()>
<cfset result.city = "">
<cfset result.state = "">
<cfhttp method="GET" url="http://www.webservicex.net//uszip.asmx/GetInfoByZIP?USZip=#arguments.zip#"/>
<cftry>
<cfset addyObj = xmlParse(cfhttp.fileconten
<cfset result.city = trim(addyObj.newDataset.ta
<cfset result.state = trim(addyObj.newDataset.ta
<cfcatch></cfcatch></cftry
<cfwddx action="cfml2js" input="#result#" toplevelvariable="r">
</CFFUNCTION>
</CFCOMPONENT>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I understand that Javascript is a key here...and I work with JS well...just not good enough to write Ajax engines...
AJax isn't the problem nor is the JavaScript engines that run it...my problem is the use of the CFFUNCTION tag in every example that I can't run on CF5.
AJax isn't the problem nor is the JavaScript engines that run it...my problem is the use of the CFFUNCTION tag in every example that I can't run on CF5.
www.newatlanta.com
Get the Dragon! We use and love BLueDragon! Of course this is an outlay of $, but to use the newer technologies, it is a move that must be made at some point.
Get the Dragon! We use and love BLueDragon! Of course this is an outlay of $, but to use the newer technologies, it is a move that must be made at some point.
ASKER
That looks a little overboard but thanks (o:
Maybe I should just host the pages that I need the AJax to run on a different server with CF7 on it and push it back to the main server once it is completed?
I do have another webserver crossed over (p2p networked) to the main application server. How does that sound?
Maybe I should just host the pages that I need the AJax to run on a different server with CF7 on it and push it back to the main server once it is completed?
I do have another webserver crossed over (p2p networked) to the main application server. How does that sound?
For your situation, that would probably work best.
ASKER
What cha think mrichmon?
Thanks
Thanks
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 guys...you've been a big help (o:
Now you most likely won't be able to use a pre-built tag, but simply write it yourself.
>>I need AJAX to make up for my lacking JavaScript skills
The J in AJAX stands for Javascript. You can't expect AJAX to "make up" for lacking skills. If the tags people have offered to share - more likely written using newer technologies like CF MX - don't work for you then you need to write it yourself, but it requires extensive javascript to do so.