Solved

How to update db using cfc and CFajaxproxy

Posted on 2008-10-24
7
520 Views
Last Modified: 2013-12-20
hey all, I have been playing with the CFAjax proxy tag within cf 8.  I have successfully managed to populate from the cfc and also upon selection of a dropdown (displaying records).  now I am having a hard time figuring out how to get to the next level which for me is to perform and update of the database on the fly using the same method (cfajaxproxy).  Can anyone please help me out here I am hitting a brick wall.
0
Comment
Question by:jriver12
  • 5
  • 2
7 Comments
 
LVL 13

Accepted Solution

by:
srikanthmadishetti earned 500 total points
ID: 22797362
ColdFusion.Ajax.submitForm('formID', '/cfcs/echo.cfc?method=doEcho', echoReturn, ajaxError);

use ColdFusion.Ajax.submitForm to submit to cfc .

0
 

Author Comment

by:jriver12
ID: 22797395
srikanthmadishetti, thanks for the pointer and quick response can you provide a basic example?
0
 

Author Closing Comment

by:jriver12
ID: 31509684
srikanthmadishetti, thanks for the pointer, just needed to dive into my own code a bit more thanks.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 22831014
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example of Using CFGrid</title>
<script type="text/javascript">
   
      function updateErrorHandler(id,message) {
      
            alert("Error while updating\n Error code: "+id+"\n Message: "+message);
      
      }
      
      
      function doInsertEmployee() {
      
        /*
        arguments are form name, cfc and method to send form values to, javascript function to handle result,
         javascript function to handle error
        */
        ColdFusion.Ajax.submitForm('insertForm', 'test.cfm', resultInsertHandler, insertErrorHandler);
              
      }
      
      
      function resultInsertHandler() {
      

            var resultDiv = document.getElementById("result");
            
            resultDiv.innerHTML = "<p>Task Added.</p>";
            
            //refresh the grid and keep grid on current page
            ColdFusion.Grid.refresh('employeeGrid', true);
            
            var aForm=document.forms.insertForm;
        aForm.reset()

      
      }
      
      
      function insertErrorHandler(id, message) {
      
         alert("Error while updating\n Error code: "+id+"\n Message: "+message);

            var resultDiv = document.getElementById("result");
            
            resultDiv.innerHTML = "<p>TASK NOT Added.</p>";
      
      }
      

      

</script>
</head>
<body>


<h3>Tasks</h3>

<cflayout type="hbox" name="layout1" padding="20px">

<cflayoutarea>
     <p>Add New Task</p>
      <cfform name="insertForm" format="html" >
      
            Task Title: <cfinput type="text" name="task_title" id="firstName"><br>
            Details: <cfinput type="text" name="details" id="lastName"><br>
            Assign by: <cfinput type="text" name="assigned_by" id="email"><br>

          <cfinput type="button" name="insertEmployee" value="Add Task" onClick="doInsertEmployee();" /><br/>
            
            
            
      </cfform>
      
      <!--used to display result of adding a new employee-->
      <div id="result">
      </div>

</cflayoutarea>
0
 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 22831043
sorry instead of that test.cfm use ur cfc with ? url parameter function name
0
 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 22831107
<cffunction name="insertData" access="remote" output="false"  returntype="void">

    <cfargument name="request_id">
      <cfargument name="task_title">
      <cfargument name="details">
      <cfargument name="assigned_by">

            
<cfquery name="tsst" datasource="req">
            
            insert into tbl_tasks ( task_title, details, assigned_by,assigned_to,status)
            values (
            

                  <cfqueryparam cfsqltype="cf_sql_varchar" value="#task_title#">,
                  <cfqueryparam cfsqltype="cf_sql_varchar" value="#details#">,
                  <cfqueryparam cfsqltype="cf_sql_varchar" value="#assigned_by#">,
                  'test',
                  'T'
            
            
            )

</cfquery>
      
</cffunction>
0
 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 22831121
the above is the function to insert and ColdFusion.Ajax.submitForm('insertForm', 'test.cfc?method=insertData, resultInsertHandler, insertErrorHandler);
use dis
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
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…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now