• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ColdFusion error: Addcategory is undefined...

Community Beginner ,
Mar 20, 2019 Mar 20, 2019

Copy link to clipboard

Copied

[ussnorway title cut back...

I have been trying to insert values into sql table using ajax,jquery and cfml. Though the values are been inserted its throwing an error before insertion. looking for the solution, Thanks in advance...]'

addcategory.cfml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>AddCategory</title>

</head>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            $('#addCategory').click(function() {

                var addcategory = $('#category').val();

  alert('data has been stored to database');

                $.ajax({

                    type: "POST",

                    url: 'addcategory.cfc',

                    data: {category: addcategory},

                    success: function(data) {

                        alert('data has been stored to database');

                    }

                });

            });

        });

    </script>

</head>

<body>

<form name="category" id="category" method="post" action="addcategory.cfml">

<tr>

    <td>

         Add Category:

    </td>

<input type ="text" placeholder ="AddCategory"  name="addcategory" id="addcategory" value="">

<input type="submit" value="Insert" id="addCategory" />

</tr>

<cfquery name="category" datasource="myapp">

     INSERT INTO category(categoryname) VALUES ('#Form.addcategory#')

</cfquery>

</body>

<script>

</body>

</html>

addcategory.cfc

<cfcomponent output="false">

    <cffunction name="insertcategory" access="remote" returntype="struct">

     <cfargument name="page" type="numeric" required="yes">

        <cfargument name="pageSize" type="numeric" required="yes">

        <cfset var category=queryNew("")>

 

 

  <cfquery name="category" datasource="myapp">

     INSERT INTO category(categoryname) VALUES ('#Form.addcategory#')

  </cfquery>

  <cfoutput> #inserted# </cfoutput>

  <cfreturn QueryConvertForGrid(local.category,

                            ARGUMENTS.page,

                            ARGUMENTS.pageSize)>

  </cffunction>

</cfcomponent>

I have been trying to insert values into sql table using ajax,jquery and cfml. Though the values are been inserted its throwing an error before insertion.

looking for the solution, Thanks in advance...

Views

472

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation