Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

AJAX on ColdFusion 5 Server

Posted on 2006-06-06
10
Medium Priority
?
426 Views
Last Modified: 2013-12-24
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

0
Comment
Question by:inverted_2000
  • 5
  • 3
  • 2
10 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 16844301
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.
0
 
LVL 2

Author Comment

by:inverted_2000
ID: 16844644
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>


0
 
LVL 9

Assisted Solution

by:73Spyder
73Spyder earned 800 total points
ID: 16844661
We have found that there is not one flavor of AJX that works best.  We use a hodge podge of things.


Here are some of the sites:

http://openrico.org/rico/home.page
http://bluedragon.blog-city.com/ajaxlibraries.htm

Mix of AJAX & DHTML : http://www.dhtmlgoodies.com/

But as mrichmon stated none of these avoid javascript.
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
LVL 2

Author Comment

by:inverted_2000
ID: 16844702
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.
0
 
LVL 9

Expert Comment

by:73Spyder
ID: 16844743
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.

0
 
LVL 2

Author Comment

by:inverted_2000
ID: 16844820
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?
0
 
LVL 9

Expert Comment

by:73Spyder
ID: 16844837
For your situation, that would probably work best.

0
 
LVL 2

Author Comment

by:inverted_2000
ID: 16844959
What cha think mrichmon?

Thanks
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 1200 total points
ID: 16845119
Just got the emails.

Personally I never have used the pre-built AJAX tags.  Nor have I used cffunction.

Of course it is not a nice neat package either.

I have notbeen programming in CF lately, so most of my AJAX experience is in .NET
But again not using the pre-built tags.

So, how would you do this?

Well there are many ways.

One example:

function DoCallback(pageUrl)
{
      var xmlRequest;
      
      // branch for native XMLHttpRequest object
      if (window.XMLHttpRequest) {
        xmlRequest = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
        xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
      }
      
      xmlRequest.open("POST", pageUrl, false);
      xmlRequest.send("");

      return xmlRequest;
}

Then the function that initiates the callback such as an onblur or onchange or onclick:

function lookupPerson()
{
      // Send lookup in Database
      var xmlRequest = DoCallback("Lookup.cfm?CallBack=true&PersonID=" + personID);
                  
      // Get results
      var results = xmlRequest.responseText;

      // Process results any way you want
}

As simple as that for the page.

Then the Lookup.cfm page is where you have the code to do the lookup.

It doesn't need cffunction - all it needs to do is the lookup you require using a cfquery and return the results in your desired format.  You could return a string.  You could return an XML file.  Whatever you return will end up in the results variable in the above javascript and you process knwing what the format is of what you sent.

0
 
LVL 2

Author Comment

by:inverted_2000
ID: 16852203
Thanks guys...you've been a big help (o:
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

577 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