Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8497821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:14:04+00:00 2026-06-11T00:14:04+00:00

I have an AJAX call to a remote CFC and get the data back

  • 0

I have an AJAX call to a remote CFC and get the data back with JSON just how I like, but I’m having trouble outputting the data without having to guess the structure index with hardcoded index values such as: $(‘#result’).val( obj.DATA[0][3] );

If I hardcode the index such as [3] if I change the query in the CFC I have to change the AJAX result. So I want to refer to the returned data by the colmn name but can’t figure it out. Here’s my AJAX and the result from a remote CFC:

$.ajax({
            url: '/app/components/MailingsReport.cfc',
            //POST method is used
            type: "POST",
            //pass the data 
            data: {
                method: "getCreativeByID",
                creativeID: $('#hdnCreativeID').val(),
                datasource: "shopping_cart",
        queryformat: "column"
                 },
            success: function(response){
                var obj = $.trim(response);
        var obj = jQuery.parseJSON(obj);
                //alert("response");
                $('#txtSubject').val( obj.COLUMNS["SUBJECT"][0] );
                }
            }

        });

CFC:

<!---gets the data for the creative--->
    <cffunction name="getCreativeByID" returntype="any" returnformat="JSON" access="remote" output="No">
        <cfargument name="creativeID" required="Yes" type="numeric" />
        <cfargument name="datasource" required="Yes" type="string" />

        <!--- Select creatives and {clickurl} --->
        <cfquery name="qGetCreativeData" datasource="#arguments.datasource#">
            exec sp_get_email_creative @creativeid = #arguments.creativeID#
        </cfquery>

        <cfreturn qGetCreativeData />

    </cffunction>

Result:

This is the result from the CFC

Any help would be appreciated! Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:14:06+00:00Added an answer on June 11, 2026 at 12:14 am

    This works in everything except IE8 and below. if you need full compatibility you could write your own indexOf JS method.

    $('#result').val( obj.DATA[0][ obj.COLUMNS.indexOf('Creativename') ] );
    

    If you need it, this page has the instructions on adding the indexOf to your array prototypes in browsers that don’t support it directly: http://www.tutorialspoint.com/javascript/array_indexof.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an ajax call $.ajax({ url: '<%=Url.Action(SaveDetails,Survey) %>', dataType: 'JSON', cache: false, data:
I have an ajax call that fires multiple times but is called once. function
I have an ajax call. I put the return value (data) in a variable
I'm trying to get my AJAX call working with the rails 3, but I'm
JSON allows you to retrieve data in multiple formats from an AJAX call. For
I have an ajax call in my code. What I want to achieve with
I have an AJAX call getting info out of the Github API. It is
I have a ajax call on my onkeyup event, that checks if the given
If I have an ajax call off fetching (with a callback) and then some
I have a jQuery ajax call that returns html of a table. Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.