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 7412973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:37:27+00:00 2026-05-29T06:37:27+00:00

I’m working on implementing a uniform error handler for remote cfc methods following Ben

  • 0

I’m working on implementing a uniform error handler for remote cfc methods following Ben Nadel’s model. Before getting to this point, I was just returning the data object to jqGrid in the form that it expects. Now, I’m returning a response object that looks like so:

RESPONSE.SUCCESS = "true/false"
RESPONSE.ERRORS = [array of errors]
RESPONSE.DATA = {normal data object that jqGrid expects}

So, I now need to massage the response object when it returns so that I have a

RESPONSE.SUCCESS == "true" 

handler that, at the very least, maps RESPONSE.DATA to the data object that jqGrid expects, and also a

RESPONSE.SUCCESS == "false"

handler that does something else. My first thought was to try to implement the beforeProcessing option. However, if I add this to my initialization code:

beforeProcessing: function(data, status, xhr) {
    console.log(data + ' beforeProcessing was called');
},...

nothing ever gets logged, either on initialization or on subsequent calls. Also, if I revert to my original code and successfully reload the grid, nothing ever runs inside

beforeProcessing: function(){
    alert('hi');
    console.log('hi there');
},...

which would seem to indicate that beforeProcessing is broken.

If I can’t get this to work, I’m going to try to implement ajaxGridOptions{} but can’t figure out exactly what needs to be set in there – I haven’t found the documentation to be much help.

  • 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-29T06:37:28+00:00Added an answer on May 29, 2026 at 6:37 am

    I think there are a misunderstanding about the usage of Ajax and loading of grid from the server. The Ajax use HTTP protocol internally which divide clear successful responds from the error responds. If the server detect any kind of error it should set error HTTP status (see here or here). In
    case of HTTP status code 400 and higher the loadError callback will be called instead of loadComplete. The format of the error response can be absolutely another as the format of successful response.

    So I see no reason the has all SUCCESS, DATA and ERRORS blocks. Boolean SUCCESS will be clear from the context: it’s equal to false inside of loadError and it’s to true inside of loadComplete. RESPONSE.DATA can be directly the body of the response. and the RESPONSE.ERRORS can be the body of the error response.

    It’s the reason why both loadError and loadComplete callbacks exists.

    The beforeProcessing will be called only in case of successful response. The statement console.log(data); will don’t display the needed information because data will be object and the text like LOG: [object Object] beforeProcessing was called which will be produced by console.log(data + ' beforeProcessing was called'); get not much information.

    UPDATED: I don’t know ColdFusion and it’s restriction in the error handling. If you really can only to return in success case the data like

    {
        "SUCCESS": true,
        "ERRORS": [],
        "DATA": {
            "TOTAL": xxx, 
            "PAGE": "yyy", 
            "RECORDS": "zzz",
            "ROWS": [
                {"ID": "id1", "CELL": ["cell11", "cell12", "cell13"]},
                {"ID": "id2", "CELL": ["cell21", "cell22", "cell23"]},
                ...
            ]
        }
    }
    

    and in the case of an error

    {
        "SUCCESS": true,
        "ERRORS": ["Any error description"],
        "DATA": {
        }
    }
    

    then you can do the following.

    First of all you should define jsonReader option of jqGrid which corresponds to successful data:

    jsonReader: {
        root: "DATA.ROWS",
        page: "DATA.PAGE",
        total: "DATA.TOTAL",
        records: "DATA.RECORDS",
        id: "ID"
    }
    

    To be able to read the error response you can place empty "DATA" part in the response inside of beforeProcessing:

    beforeProcessing: function (data) {
        if (!data.SUCCESS) {
            // error response. we set empty "DATA"
            data.DATA = {TOTAL: 0, PAGE: 0, ROWS: []};
    
            // now the data.ERRORS should be processed
            alert (data.ERRORS.join(','));
        }
    }
    

    In the real world you should display the error messages from data.ERRORS in some div or dialog instead of usage of alert, but the general schema described above should work.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.