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

  • Home
  • SEARCH
  • 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 725977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:23:56+00:00 2026-05-14T06:23:56+00:00

I need to return multiple values from a ColdFusion function in an ajax callback

  • 0

I need to return multiple values from a ColdFusion function in an ajax callback function. Here’s what I’ve got:

$('input[name="StateName"]').live('change', function() {
    var StateID = $(this).parents('tr').attr('id');
    var StateName = $(this).val();
    $.ajax({
        url: 'Remote/State.cfc'
        ,type: "POST"
        ,data: {
            'method': 'UpdateStateName'
            ,'StateID': StateID
            ,'StateName': StateName
        }
        ,success: function(result){
            if (isNaN(result)) {
                $('#msg').text(result).addClass('err');
            } else {
                $('#' + result + ' input[name="StateName"]').addClass('changed');
            };
        }
        ,error: function(msg){
            $('#msg').text('Connection error').addClass('err');
        }
    });
});

If I trap a database error, then the success callback is fired, and the result is Not a Number (It is in fact, the text of the error message). I need the function to also pass back other values. One might be the primary key of the row that caused the error. Another might be the old StateName, so that I can refresh the old value on the screen so that the client will know absolutely for sure that their change did not take effect.

I guess I’m breaking the rule of atomicity here and need to fix that, because I’m using result as both the primary key of the row that was updated, or it’s the error message if the update fails. I need to return both the primary key and the error message.

  • 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-05-14T06:23:57+00:00Added an answer on May 14, 2026 at 6:23 am

    Your remote function could return a **JSON string**, containing an object, I suppose.

    It would allow you to have several values inside a single “value”.

    And JSON being Javascript Object Notation, it’s quite easy to read it in Javascript — and there are libraries to serialize data to JSON in lots of languages.

    For example, here’s a JSON string :

    {"status":1,"message":"this is a message","data":{"test":"plop","hello":"world"}}
    

    This corresponds to an object with 3 properties :

    • status
    • message
    • and data ; which is itself another object, that contains two properties.

    Returning this kind of string from your AJax call should not be too hard — and that’s a pretty flexible, and really prowerful, system.

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

Sidebar

Ask A Question

Stats

  • Questions 354k
  • Answers 354k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you type this: public event EventHandler MyEvent; what the… May 14, 2026 at 8:22 am
  • Editorial Team
    Editorial Team added an answer it means "and". -o is "or". From man bash expr1… May 14, 2026 at 8:22 am
  • Editorial Team
    Editorial Team added an answer echo something >&2 is the correct way to do what… May 14, 2026 at 8:22 am

Related Questions

I asked a similar question, but I couldn't get it working exactly. I'm building
Given a set of tuple classes in an OOP language: Pair, Triple and Quad,
I'm trying to write a trigger in MySQL and I need to set the
Ok, I have a question relating to an issue I've previously had. I know
I have the following challenge, and I haven't found a good answer. I am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.