?
Solved

How to update db using cfc and CFajaxproxy

Posted on 2008-10-24
7
Medium Priority
?
543 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 13

Accepted Solution

by:
srikanthmadishetti earned 2000 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
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

 
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

Limited time offer using promo code EXPERTS25

Designed with a wealth of functionality and convenience, ATEN's new Thunderbolt™ 2 Sharing Switch takes your Thunderbolt setup to the next level. Now through August 31, 2017, Experts Exchange members get 25% off the US7220 on the ATEN USA eShop using promo code EXPERTS25.

Question has a verified solution.

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

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
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 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

771 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