Solved

How to update db using cfc and CFajaxproxy

Posted on 2008-10-24
7
528 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 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
spamming  on Hosted svrs? 6 109
http to https 3 83
Soundcloud.com 4 113
IIS Authentication Error 401 16 72
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

734 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