Solved

How to update db using cfc and CFajaxproxy

Posted on 2008-10-24
7
518 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

759 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

22 Experts available now in Live!

Get 1:1 Help Now