Well, I don't know what standardiseCfQueryJSON does, but here's what I do:
<cffunction name="listFields" displayname="List Fields"  access="remote"
returntype="query">
<cfargument name="growerID" displayName="Grower ID" type="numeric" hint="I
am the Grower ID" required="true" />

<cfset var q = ''/>
 <cfquery name="q">
Select * from `field`
where g_id = <cfqueryparam value="#arguments.growerid#"
cfsqltype="cf_sql_integer" />
order by fieldname
</cfquery>
 <Cfif q.recordcount eq 0>
<Cfset q = queryNew("f_id,FieldName")>
<Cfset queryAddRow(q,1)/>
<Cfset q.f_id = 0/>
<Cfset q.fieldname=''/>
</cfif>
 <Cfreturn q/>
</cffunction>

and then on the calling page:

  $.ajax({
                        type: 'get',
                        url: '/cfcs/field/fields.cfc',
                        data: {
                            method: 'fieldData',
                            fieldID: $("#fielder").val()
                        },
                        dataType: 'json',
                        success: function (result) {
                                $("#fieldname").val(result.DATA[0][2]);
                                $("#acres").val(result.DATA[0][12]);
                                $("#911num").val(result.DATA[0][6]);
}
});

You are taking a Query and putting it in a struct.  I would either leave it
a query (as Above) or put it in an array

HTH,

Rob




On Fri, 6 Mar 2015 at 10:20 Torrent Girl <moniqueb...@gmail.com> wrote:

>
> Hello
>
> I have the following json call:
>
> <script>
> $.ajax({
>         url:"data.cfc?method=getData"
>         ,dataType:"json"
>         ,success: function( cfdata ){
>             data    =   $.standardiseCfQueryJSON( cfdata );
>             // do something with the data
>              return data;
>         }
> });
> </script>
>
>
>
>
> Here is my cfc
>
> <cffunction name="getData" access="remote" returntype="any"
> returnformat="json">
>
> <cfquery name="qryLoc" datasource="cfartgallery">
> select * from artists
> </cfquery>
>
> <cfoutput>
> <cfset i = 1>
> <cfset data = ArrayNew(1)>
> <cfloop query="qryLoc">
> <cfset row = StructNew()>
> <cfset row["artistID"] = "#qryLoc.artistID#">
> <cfset row["firstName"] = "#qryLoc.firstName#">
> <cfset row["locfstname"] = "#qryLoc.lastname#">
> <cfset data[i]  = row>
> <cfset i = i + 1>
> </cfloop>
>
> <cfreturn #serializeJSON(data)#>
> </cfoutput>
> </cffunction>
>
>
>
>
> How do I access and then output the data returned?
>
>
> Thanks
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360219
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to