Link to home
Start Free TrialLog in
Avatar of inverted_2000
inverted_2000Flag for United States of America

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

Avatar of mrichmon
mrichmon

You can use AJAX.  AJAX is just a method of calling back using javascript and xml.  It has nothing to do with what server languge you are using.

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.
Avatar of inverted_2000

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_request(#employeeId#);'>#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,city,region,postalcode,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.firstname#">,
                                    lastName= <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.lastname#">,
                                    hireDate = <cfqueryparam cfsqltype="CF_SQL_DATE" value="#createODBCdate(arguments.hiredate)#">,
                                    notes = <cfqueryparam cfsqltype="CF_SQL_LONGVARCHAR" 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.filecontent)>
                  <cfset result.city = trim(addyObj.newDataset.table.city.xmlText)>
                  <cfset result.state = trim(addyObj.newDataset.table.state.xmlText)>
            <cfcatch></cfcatch></cftry>
            
      <cfwddx action="cfml2js" input="#result#" toplevelvariable="r">
      </CFFUNCTION>
      
      
</CFCOMPONENT>


SOLUTION
Avatar of 73Spyder
73Spyder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.

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?
For your situation, that would probably work best.

What cha think mrichmon?

Thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks guys...you've been a big help (o: