Skip navigation
Currently Being Moderated

pass coldfusion data to jQuery DatePicker using jQuery.get()

Aug 23, 2013 10:58 AM

I use following jQuery code to pass json data from ColdFusion  using jQuery.get() to datepicker.

I tested the server side and it returns data without error.

I got 'I am here' and 'Data Loaded:" message from alert.

The click evnet is triggered, but it does not go in to success callback function.

Any information and help is great appreciated,






Her is client side coe:


jQuery("#btnTest").click( function() {
   alert(' I am here');

        url: 'MyServer.cfc?method=MyMethod&vMyNumber=5',
        datatype: 'json',
        success: function(data)
       alert(" i am inside");
       jQuery("#MyDate").datepicker('setDate', data.MyDate);
       console.log( data );
    alert("Data Loaded: ");


here is ColdFusion Server  side code:


<cffunction name="MyMethod" access="remote" returnformat="json">
  <cfargument name="vMyNumber" required="yes" default="0" hint="My Number">
  <cfargument name="page" required="no" default="1" hint="Page user is on">
  <cfargument name="rows" required="no" default="10" hint="Number of Rows to display per page">
  <cfargument name="sidx" required="no" default="" hint="Sort Column">
  <cfargument name="sord" required="no" default="ASC" hint="Sort Order">

<cfset var Mydata = ArrayNew(1)>

<cfset start = ((*arguments.rows)+1>
<cfset end = (start-1) + arguments.rows>
<cfset i = 1>

<cfstoredproc procedure="mySP">
<cfprocparam value = "#vMyNumber#" CFSQLTYPE = "cf_sql_integer">
<cfprocresult name="MyProp" resultset="1">

<cfloop query="MyProc" startrow="#start#" endrow="#end#">

       <cfset Mydata[i] = [#MyNumber#,#MyDate#]>

            <cfset i = i + 1>           

     <cfset totalPages = Ceiling(MyProp.recordcount/arguments.rows)>
     <cfset stcReturn =     {total=#totalPages#,,records=#MyProp.recordcount #,rows=#Mydata#}>


<cfreturn stcReturn>




Here is data returned from ColdFusion Server.


{"ROWS":[[6,"May, 03 2002 00:00:00"]],"PAGE":1,"RECORDS":1,"TOTAL":1.0}

  • Currently Being Moderated
    Aug 23, 2013 5:47 PM   in reply to iccsi

    First off all, when you declare a local variable in a function, use "var" scope. This will prevent problem in the future when your app gets bigger and somewhere you use the same variable names.


    Now, let's talk about the jQuery.

    1. Why you use .get() method? It is critical that you know what you are doing since this problem is very similar to the one that you had before.

    2. .datepicker('setDate', data.MyDate); -- Where does .MyDate refer to?

    3. It would be wise that you make sure your document is ready before allowing user clicking something.

    Mark as:
  • Currently Being Moderated
    Aug 23, 2013 7:57 PM   in reply to iccsi

    I don't understand what you are trying to do with .get() method. Why not .ajax() method?

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points