Solved

How to update db using cfc and CFajaxproxy

Posted on 2008-10-24
7
524 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unsearchable in Google,Yahoo and Bing. 6 66
SCCM vs Windows server 5 86
Column Spacing 3 108
Help with a redirect in web.config file 8 63
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
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 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…

685 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