I need to return multiple values from a ColdFusion function to an ajax callback function. Here is what I have:
$('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 catch a database error, then the success callback is executed and the result is not a number (actually this is the text of the error message). I need a function to pass other values. One of them may be the primary key of the line that caused the error. The old StateName may be another, so I can update the old value on the screen so that the client knows exactly that their changes have not taken effect.
, , , , . , .